In python I can use this to check if the element in list a
:
>>> a = range(10)
>>> 5 in a
True
>>> 16 in a
False
Range has the === method, which checks whether the argument is part of the range.
You use it like this:
(1..10) === 5 #=> true
(1..10) === 15 #=> false
or as you wrote it:
a= (1..10)
a === 5 #=> true
a === 16 #=> false
You must be sure the values of the range and the value you are testing are of compatible type, otherwise an Exception will be thrown.
(2.718..3.141) === 3 #=> true
(23..42) === "foo" # raises exception
If you want to see the difference, open irb and type:
(1..10**9) === 5 #=> true
(1..10**9).to_a.include?(5) # wait some time until your computer is out of ram and freezess