Skip to content

Latest commit

 

History

History
23 lines (17 loc) · 316 Bytes

case-on-ranges.md

File metadata and controls

23 lines (17 loc) · 316 Bytes

Case on ranges

age = rand(1..100)
p age

case age
  when -Float::INFINITY..20
    p 'You are too young'
  when 21..64
    p 'You are at the right age'
  when 65..Float::INFINITY
    p 'You are too old'
end

# Result:
# 55
# "You are at the right age"

View Source