summaryrefslogtreecommitdiff
path: root/lib/set.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/set.rb')
-rw-r--r--lib/set.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/set.rb b/lib/set.rb
index bfa37d4dc0..009721381b 100644
--- a/lib/set.rb
+++ b/lib/set.rb
@@ -475,6 +475,23 @@ class Set
@hash.eql?(o.instance_variable_get(:@hash))
end
+ # Returns true if obj is a member of the set, and false otherwise.
+ #
+ # Used in case statements:
+ #
+ # case :apple
+ # when Set[:potato, :carrot] then 'vegetable'
+ # when Set[:apple, :banana] then 'fruit'
+ # end
+ # #=> "fruit"
+ #
+ # Or by itself:
+ #
+ # Set[1, 2, 3] === 2 #=> true
+ # Set[1, 2, 3] === 4 #=> false
+ #
+ alias === include?
+
# Classifies the set by the return value of the given block and
# returns a hash of {value => set of elements} pairs. The block is
# called once for each element of the set, passing the element as