ruby入门_case

看例子就可以了

num = 90

case num
when 0..59
  puts "fight"
when 60..89
  puts "good"
when 90..99
  puts "nice"
when 100
  puts "best"
else
puts "something wrong!!!"
end


你可能感兴趣的:(ruby入门_case)