How to check if number is in x..y?

Hi all

I’m still quite new to Ruby, and I wonder what’s the easiest way to
check if a number is in the range x…y?

E.g.

Is 10 in the range 5…123?

Thanks for help,
Josh

nums = 5…123

if nums.include?(10)

puts “yes”

end

On Aug 15, 7:06 pm, Joshua M. [email protected]

Shuaib Z. wrote:

nums = 5…123

if nums.include?(10)

puts “yes”

end

On Aug 15, 7:06�pm, Joshua M. [email protected]

Thanks :slight_smile:

nums === 10 does the same.

range === val returns true if range.start <= val <= range.end

dirk.