我想这样做:
case cost
when cost between 1 and 3 then cost * 1.1
when cost between 3 and 5 then cost * 1.2
else
0
我想这样做:
case cost
when cost between 1 and 3 then cost * 1.1
when cost between 3 and 5 then cost * 1.2
else
0
是的,因为Range#===
的定义与include?
相同,所以可以在case
条语句中使用范围:
case cost
when 1..3 then cost * 1.1
when 3..5 then cost * 1.2