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
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
Shuaib Z. wrote:
nums = 5…123
if nums.include?(10)
puts “yes”
end
On Aug 15, 7:06�pm, Joshua M. [email protected]
Thanks
nums === 10 does the same.
range === val returns true if range.start <= val <= range.end
dirk.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs