Control Flow Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

If you want to see whether the value of a variable is in the range of lets say one to 10(including 10) what are three different ways you could do this?

A

age.gets.chomp.to_i

if (0..10) === age
puts “Yes!”
end

if (0.10).include?(age)
puts “Yes!”
end

case age
when 0..10 then puts “Yes!”
end

How well did you know this?
1
Not at all
2
3
4
5
Perfectly