Maintenance Ruby 3.4 gets fixes, but no new features. Switch to Ruby 4.0 →
instance method
Set#collect!
() { (A) -> A } -> self
collect!() { |o| ... }
lib/set.rb
View on GitHub ↗
# File tmp/rubies/ruby-3.4.1/lib/set.rb, line 567
def collect!
block_given? or return enum_for(__method__) { size }
set = self.class.new
each { |o| set << yield(o) }
replace(set)
end
Replaces the elements with ones returned by collect(). Returns an enumerator if no block is given.
See also
#clear
#compare_by_identity
#classify
#compare_by_identity?
also in
4.1 · 4.0 · 3.3 · 3.2 · 3.1 · 3.0