I find this behavior rather strange
> [1, 2, 3, 'a', 'b', Float::NAN].include? Float::NAN
false
I tried this then and got surprised
> Float::NAN == Float::NAN
false
So, to check for Float::NAN
, I had to resort to
> [1, 2, 3, 'a', 'b', Float::NAN].any? { |i| i.is_a?(Float) && i.nan? }
true
So,
- Is there a better way to check for
Float::NAN
in an array? - Why is there such a weird behavior with
Float::NAN
?