Ensure that a Sinatra hash always has a valid value I'm trying to ensure that a Sinatra hash always has a valid value.

Is there a more-concise way to write this?

params[:v] = if [:icons,:list].include? (params[:v] ||= :list).downcase.to_sym then (params[:v] ||= :list).downcase.to_sym else :list end
I'd write this in multiple lines, so that you don't have to write out the complex conversion multiple times:

v = (params[:v] || :list).downcase.to_sym
params[:v] = if %i[icons list].include?(v) then v else :list end