From 2aee703e7a29bcfc2095e40870f5a3c45cd96dd2 Mon Sep 17 00:00:00 2001 From: knu Date: Tue, 19 Sep 2017 08:45:12 +0000 Subject: 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 --- lib/set.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'lib/set.rb') 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 -- cgit v1.2.3