[1..4].contains(2)
===> false
[1,2,3,4].contains(2)
===> true
Why the first code snippet returns false?
[1..4].contains(2)
===> false
[1,2,3,4].contains(2)
===> true
Why the first code snippet returns false?
This is a common mistake, that gets everybody at least once
This isn't a range, it's a list containing a range
[1..4]
Notice the square brackets.
What you need is regular brackets:
(1..4).contains(2)
Which will give you the result you expect