Ruby 2.6.0 リファレンスマニュアル > ライブラリ一覧 > setライブラリ > Setクラス > collect!

instance method Set#collect!

collect! {|o| ...} -> self[permalink][rdoc]
map! {|o| ...} -> self

集合の各要素についてブロックを評価し、その結果で元の集合を置き換えます。


require 'set'
set = Set['hello', 'world']
set.map! {|str| str.capitalize}
p set  # => #<Set: {"Hello", "World"}>

[SEE_ALSO] Enumerable#collect