diff options
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | lib/set.rb | 4 |
2 files changed, 8 insertions, 2 deletions
@@ -1,3 +1,9 @@ +Fri May 1 16:50:05 2009 Akinori MUSHA <knu@iDaemons.org> + + * lib/set.rb (Set#merge): Only directly use the passed objects + @hash instance variable when self and the passed object are + instances of the same class. [Bug #118] + Fri May 1 16:44:11 2009 Akinori MUSHA <knu@iDaemons.org> * lib/set.rb (SortedSet#add): Do not let an uncomparable object diff --git a/lib/set.rb b/lib/set.rb index ec42b93fab..5be2bce76a 100644 --- a/lib/set.rb +++ b/lib/set.rb @@ -276,8 +276,8 @@ class Set # Merges the elements of the given enumerable object to the set and # returns self. def merge(enum) - if enum.is_a?(Set) - @hash.update(enum.instance_eval { @hash }) + if enum.instance_of?(self.class) + @hash.update(enum.instance_variable_get(:@hash)) else enum.each { |o| add(o) } end |