Skip to content

Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →

instance method

Set#to_a

() -> ::Array[A]
to_a → array

Returns an array containing the elements of self:

Example
Set[1, 2].to_a       # => [1, 2]
Set[1, 'c', :s].to_a # => [1, "c", :s]

Related: Methods for Converting.

See also #superset? #to_s #subtract #to_set also in 4.0 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0