From: "simonrussell (Simon Russell)" <spam+ruby@...> Date: 2013-01-10T09:20:06+09:00 Subject: [ruby-core:51336] [ruby-trunk - Bug #7676] Comparison of Float::NAN in array behaves unexpectedly Issue #7676 has been updated by simonrussell (Simon Russell). This isn't just Float::NAN, actually; as Charlie's patch shows, it's actually any object that always returns false from == 1.9.3p125 :001 > class X 1.9.3p125 :002?> def ==(other) 1.9.3p125 :003?> false 1.9.3p125 :004?> end 1.9.3p125 :005?> end => nil 1.9.3p125 :006 > x = X.new => #<X:0x00000000ba1648> 1.9.3p125 :007 > x == x => false 1.9.3p125 :008 > [x] == [x] => true Is this desirable behaviour? ---------------------------------------- Bug #7676: Comparison of Float::NAN in array behaves unexpectedly https://bugs.ruby-lang.org/issues/7676#change-35306 Author: simonrussell (Simon Russell) Status: Rejected Priority: Normal Assignee: Category: Target version: ruby -v: ruby 1.9.3p362 (2012-12-25 revision 38607) [x86_64-linux] It seems that two arrays containing Float::NAN will be considered equal ([Float::NAN] == [Float::NAN]), despite the fact that Float::NAN != Float::NAN. Tested and reproduced in 1.8.7p371, 1.9.3p362, 2.0.0preview2. (This bug can be reproduced in Ruby 1.8 as well.) Results below. 1.8.7 p371 --------- 1.8.7 :001 > nan = 0.0/0.0 => NaN 1.8.7 :002 > nan == nan => false 1.8.7 :003 > [nan] == [nan] => true 1.9.3 p362 --------- 1.9.3p362 :001 > Float::NAN == Float::NAN => false 1.9.3p362 :002 > [Float::NAN] == [Float::NAN] => true 2.0.0 preview2 -------------- 2.0.0dev :001 > Float::NAN == Float::NAN => false 2.0.0dev :002 > [Float::NAN] == [Float::NAN] => true -- http://bugs.ruby-lang.org/