It’s Rails/Ruby. Just wondering if there is a DRYer version to remove the repetition in the following code:
case params[:order]
when 'rating_ascend'
order = {:order => 'rating_average ASC'}
when 'rating_descend'
order = {:order => 'rating_average DESC'}
when 'distance'
order = {:order => 'distance ASC'}
else
order = {:order => 'distance ASC'}
end
Thanks.
Or course, there is.
Or even this (I wouldn’t write like this, but this is DRYer)
When you simplify code to this point, you notice that you have double “distance ASC” result. Is it a typo or intentional?