它是 Rails/Ruby。只是想知道是否有 DRYer 版本可以删除以下代码中的重复:
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
谢谢。