mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* lib/set.rb (SortedSet#add): Do not require each newly added
element to be Comparable but to respond to <=>. [ruby-dev:38371] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23363 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
a090192032
commit
77b04fb6d5
2 changed files with 9 additions and 4 deletions
|
@ -1,3 +1,8 @@
|
|||
Fri May 8 02:30:14 2009 Akinori MUSHA <knu@iDaemons.org>
|
||||
|
||||
* 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 21:42:51 2009 Yusuke Endoh <mame@tsg.ne.jp>
|
||||
|
||||
* test/ruby/test_rubyoptions.rb (test_indentation_check): add a test
|
||||
|
|
|
@ -456,8 +456,8 @@ end
|
|||
# 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>
|
||||
|
@ -506,7 +506,7 @@ class SortedSet < Set
|
|||
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
|
||||
|
@ -529,7 +529,7 @@ class SortedSet < Set
|
|||
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
|
||||
|
|
Loading…
Reference in a new issue