Skip to content

Maintenance Ruby 3.4 gets fixes, but no new features. Switch to Ruby 4.0 →

instance method

Set#to_a

() -> ::Array[A]
to_a

Returns an array containing all elements in the set.

Example
Set[1, 2].to_a                    #=> [1, 2]
Set[1, 'c', :s].to_a              #=> [1, "c", :s]
See also #superset? #to_json #subtract #to_s also in 4.1 · 4.0 · 3.3 · 3.2 · 3.1 · 3.0