End of Life Ruby 3.0 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
instance method
Set#add
add(o)
lib/set.rb
View on GitHub ↗
# File tmp/rubies/ruby-3.0.5/lib/set.rb, line 354
def add(o)
@hash[o] = true
self
end
Adds the given object to the set and returns self. Use merge to add many elements at once.
Example
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}>