aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog8
-rw-r--r--lib/set.rb31
2 files changed, 32 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index 17b7ee82f2..f46352d193 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+Tue Mar 20 11:09:00 2007 Akinori MUSHA <knu@iDaemons.org>
+
+ * lib/set.rb: Revise rdoc.
+
+ * lib/set.rb (Set#freeze, Set#taint, Set#untaint): Implement
+ Set#freeze, Set#taint, and Set#untaint; requested by: Dan
+ Hutchings <dan AT moltoagitato.com> in [ruby-bugs:PR#9359].
+
Tue Mar 20 09:13:10 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* process.c (rb_fork): flush stdouts always before fork(2).
diff --git a/lib/set.rb b/lib/set.rb
index 15f5cee7d0..12e9486ca3 100644
--- a/lib/set.rb
+++ b/lib/set.rb
@@ -28,14 +28,13 @@
# This is a hybrid of Array's intuitive inter-operation facilities and
# Hash's fast lookup.
#
-# Several methods accept any Enumerable object (implementing +each+)
-# for greater flexibility: new, replace, merge, subtract, |, &, -, ^.
-#
# The equality of each couple of elements is determined according to
# Object#eql? and Object#hash, since Set uses Hash as storage.
#
-# Finally, if you are using class Set, you can also use Enumerable#to_set
-# for convenience.
+# Set is easy to use with Enumerable objects (implementing +each+).
+# Most of the initializer methods and binary operators accept generic
+# Enumerable objects besides sets and arrays. An Enumerable object
+# can be converted to Set using the +to_set+ method.
#
# == Example
#
@@ -78,6 +77,24 @@ class Set
@hash = orig.instance_eval{@hash}.dup
end
+ def freeze # :nodoc:
+ super
+ @hash.freeze
+ self
+ end
+
+ def taint # :nodoc:
+ super
+ @hash.taint
+ self
+ end
+
+ def untaint # :nodoc:
+ super
+ @hash.untaint
+ self
+ end
+
# Returns the number of elements.
def size
@hash.size
@@ -190,7 +207,7 @@ class Set
end
# Adds the given object to the set and returns self. Use +merge+ to
- # add several elements at once.
+ # add many elements at once.
def add(o)
@hash[o] = true
self
@@ -208,7 +225,7 @@ class Set
end
# Deletes the given object from the set and returns self. Use +subtract+ to
- # delete several items at once.
+ # delete many items at once.
def delete(o)
@hash.delete(o)
self