mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
lib/set.rb: improve docs for Set#===
* lib/set.rb: [DOC] improve description and examples for Set#===. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60573 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
b1e77e85b6
commit
cd63bec1ed
1 changed files with 11 additions and 6 deletions
17
lib/set.rb
17
lib/set.rb
|
@ -490,20 +490,25 @@ class Set
|
|||
self
|
||||
end
|
||||
|
||||
# Returns true if obj is a member of the set, and false otherwise.
|
||||
# Returns true if the given object is a member of the set,
|
||||
# and false otherwise.
|
||||
#
|
||||
# Used in case statements:
|
||||
#
|
||||
# require 'set'
|
||||
#
|
||||
# case :apple
|
||||
# when Set[:potato, :carrot] then 'vegetable'
|
||||
# when Set[:apple, :banana] then 'fruit'
|
||||
# when Set[:potato, :carrot]
|
||||
# "vegetable"
|
||||
# when Set[:apple, :banana]
|
||||
# "fruit"
|
||||
# end
|
||||
# #=> "fruit"
|
||||
# # => "fruit"
|
||||
#
|
||||
# Or by itself:
|
||||
#
|
||||
# Set[1, 2, 3] === 2 #=> true
|
||||
# Set[1, 2, 3] === 4 #=> false
|
||||
# Set[1, 2, 3] === 2 # => true
|
||||
# Set[1, 2, 3] === 4 # => false
|
||||
#
|
||||
alias === include?
|
||||
|
||||
|
|
Loading…
Reference in a new issue