In a block, case..whenyou cannot perform comparisons except ===. Therefore, I will write your code as shown below:
def get_price_rank(price)
case price
when 41..50
'Sorta cheap'
when 50..60
'Reasonable'
when 60..70
'Not cheap'
when 70..80
'Spendy'
when 80..90
'Expensive!'
else
if price >= 90
'Rich!'
elsif price <= 40
'Cheap!'
end
end
end
return implicitly, so no need to mention.
source
share