summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-12-18 02:07:31 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-12-18 02:07:31 +0000
commitbf2114192918cde92221570ee760b9651d2f4443 (patch)
treed5e534cd272b29ac61a098ec492515cbf230383b /lib
parentda9e03c55f2a062987d183a1a1ea7b65b773d8ca (diff)
downloadruby-bf2114192918cde92221570ee760b9651d2f4443.tar.gz
ruby-bf2114192918cde92221570ee760b9651d2f4443.tar.xz
ruby-bf2114192918cde92221570ee760b9651d2f4443.zip
* dir.c (dir_open_dir): new function. [ruby-dev:25242]
* hash.c (Init_Hash): remove custom "hash" and "eql?". * lib/set.rb (Set::eql): wrong definition. [ruby-dev:25207] * object.c (rb_obj_id_obsolete): warn always. * eval.c (rb_enable_super): ditto. * lib/set.rb (Set#==): [ruby-dev:25206] * lib/pstore.rb (PStore#transaction): Use the empty content when a file is not found. [ruby-dev:24561] git-svn-id: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_8@7592 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r--lib/set.rb14
1 files changed, 9 insertions, 5 deletions
diff --git a/lib/set.rb b/lib/set.rb
index 23d7b847e..4a9256a33 100644
--- a/lib/set.rb
+++ b/lib/set.rb
@@ -251,7 +251,7 @@ class Set
# Merges the elements of the given enumerable object to the set and
# returns self.
def merge(enum)
- if enum.class == self.class
+ if enum.is_a?(Set)
@hash.update(enum.instance_eval { @hash })
else
enum.is_a?(Enumerable) or raise ArgumentError, "value must be enumerable"
@@ -291,7 +291,7 @@ class Set
def &(enum)
enum.is_a?(Enumerable) or raise ArgumentError, "value must be enumerable"
n = self.class.new
- enum.each { |o| include?(o) and n.add(o) }
+ enum.each { |o| n.add(o) if include?(o) }
n
end
alias intersection & ##
@@ -313,7 +313,8 @@ class Set
set.is_a?(Set) && size == set.size or return false
- set.all? { |o| include?(o) }
+ hash = @hash.dup
+ set.all? { |o| hash.include?(o) }
end
def hash # :nodoc:
@@ -321,7 +322,8 @@ class Set
end
def eql?(o) # :nodoc:
- @hash.hash == o.hash
+ return false unless o.is_a?(Set)
+ @hash.eql?(o.instance_eval{@hash})
end
# Classifies the set by the return value of the given block and
@@ -583,7 +585,9 @@ end
# else
# instance_eval %{
# def add(o)
-# @hash[o] = true if @proc.call(o)
+# if @proc.call(o)
+# @hash[o] = true
+# end
# self
# end
# alias << add