How to check if a value is included between two other values?
There are many ways of doing the same things in Ruby. You can check if value is in the range by use of following methods,
14.between?(10,20) # true
(10..20).member?(14) # true
(10..20).include?(14) # true
But, I would suggest using between
than member?
or include?
. You can find more about it here.
Ruby also has between?:
if value.between?(lower, higher)