diff options
author | knu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-09-19 08:45:12 +0000 |
---|---|---|
committer | knu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-09-19 08:45:12 +0000 |
commit | 2aee703e7a29bcfc2095e40870f5a3c45cd96dd2 (patch) | |
tree | 3ea77cd20f5e90e98356845e8dbda006bc8d9f48 /lib | |
parent | b40a9475db568d05bf33ab168ed804e3e2091293 (diff) |
Alias Set#=== to #include?
* set.rb (Set#===): Added via [Feature #13801] by davidarnold.
Closes #1673.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59966 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r-- | lib/set.rb | 17 |
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 |