ruby-changes:11722
From: knu <ko1@a...>
Date: Fri, 8 May 2009 02:36:06 +0900 (JST)
Subject: [ruby-changes:11722] Ruby:r23365 (ruby_1_8): * lib/set.rb (SortedSet#add): Do not require each newly added
knu 2009-05-08 02:35:55 +0900 (Fri, 08 May 2009) New Revision: 23365 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=23365 Log: * lib/set.rb (SortedSet#add): Do not require each newly added element to be Comparable but to respond to <=>. [ruby-dev:38371] Modified files: branches/ruby_1_8/ChangeLog branches/ruby_1_8/lib/set.rb Index: ruby_1_8/ChangeLog =================================================================== --- ruby_1_8/ChangeLog (revision 23364) +++ ruby_1_8/ChangeLog (revision 23365) @@ -1,3 +1,8 @@ +Fri May 8 02:34:25 2009 Akinori MUSHA <knu@i...> + + * lib/set.rb (SortedSet#add): Do not require each newly added + element to be Comparable but to respond to <=>. [ruby-dev:38371] + Thu May 7 13:58:52 2009 Nobuyoshi Nakada <nobu@r...> * range.c (range_eql): fixed rdoc. Index: ruby_1_8/lib/set.rb =================================================================== --- ruby_1_8/lib/set.rb (revision 23364) +++ ruby_1_8/lib/set.rb (revision 23365) @@ -446,8 +446,8 @@ # yielded in sorted order (according to the return values of their # #<=> methods) when iterating over them. # -# All elements that are added to a SortedSet must include the -# Comparable module. +# All elements that are added to a SortedSet must respond to the <=> +# method for comparison. # # Also, all elements must be <em>mutually comparable</em>: <tt>el1 <=> # el2</tt> must not return <tt>nil</tt> for any elements <tt>el1</tt> @@ -496,7 +496,7 @@ end def add(o) - o.is_a?(Comparable) or raise ArgumentError, "value must be comparable" + o.respond_to?(:<=>) or raise ArgumentError, "value must repond to <=>" super end alias << add @@ -519,7 +519,7 @@ end def add(o) - o.is_a?(Comparable) or raise ArgumentError, "value must be comparable" + o.respond_to?(:<=>) or raise ArgumentError, "value must respond to <=>" @keys = nil super end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/