Project

General

Profile

Actions

Bug #5285

closed

Ruby 1.9.2 throws exception on sort of array containing true AND false values

Added by mcorino (Martin Corino) over 12 years ago. Updated over 12 years ago.

Status:
Rejected
Assignee:
-
Target version:
ruby -v:
ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-linux]
Backport:
[ruby-core:39304]

Description

I encountered a very weird bug.

Sorting of arrays containing identical boolean values (ALL true or ALL false) works fine.
As soon as 1 value differs however #sort throws an exception.

ruby-1.9.2-p290 :001 > [true, true].sort
=> [true, true]

ruby-1.9.2-p290 :002 > [false, false].sort
=> [false, false]

ruby-1.9.2-p290 :003 > [false, true].sort
ArgumentError: comparison of FalseClass with true failed
from (irb):3:in sort' from (irb):3 from /home/martin/.rvm/rubies/ruby-1.9.2-p290/bin/irb:16:in '

ruby-1.9.2-p290 :004 > [false, true, false].sort
ArgumentError: comparison of FalseClass with true failed
from (irb):4:in sort' from (irb):4 from /home/martin/.rvm/rubies/ruby-1.9.2-p290/bin/irb:16:in '

ruby-1.9.2-p290 :011 > [true, true, true, true].sort
=> [true, true, true, true]

ruby-1.9.2-p290 :012 > [true, true, true, false].sort
ArgumentError: comparison of TrueClass with false failed
from (irb):12:in sort' from (irb):12 from /home/martin/.rvm/rubies/ruby-1.9.2-p290/bin/irb:16:in '

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0