Ruby writes case expression.
score = 70
result = case score
when 0..40 then "F"
when 41..60 then "C"
when 61..70 then "B"
when 71..100 then "A"
else "Invalid input"
end
puts result
Each
You can interpret it like this.
© 2024 OneMinuteCode. All rights reserved.