End of Life Ruby 3.2 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
instance method
Set#<<
<<(o)
lib/set.rb
View on GitHub ↗
# File tmp/rubies/ruby-3.2.0/lib/set.rb, line 521
def add(o)
@hash[o] = true
self
end
Alias of #add
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}>