From 4503c8daebd2b8c572a313117b5d9c50e824ab14 Mon Sep 17 00:00:00 2001 From: knu Date: Tue, 20 Mar 2007 02:09:10 +0000 Subject: * 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 in [ruby-bugs:PR#9359]. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12104 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/set.rb | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) (limited to 'lib/set.rb') 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 -- cgit v1.2.3