Method: Set#add
- Defined in:
- lib/set.rb
#add(o) ⇒ Object Also known as: <<
Adds the given object to the set and returns self. Use merge to add many elements at once.
Set[1, 2].add(3) #=> #<Set: {1, 2, 3}>
Set[1, 2].add([3, 4]) #=> #<Set: {1, 2, [3, 4]}>
Set[1, 2].add(2) #=> #<Set: {1, 2}>
514 515 516 517 |
# File 'lib/set.rb', line 514 def add(o) @hash[o] = true self end |