The to_a() of enumerable is an inbuilt method in Ruby returns an array containing all the items of the enumerable.
Syntax: enu.to_a()
Parameters: The function does not accepts any parameter.
Return Value: It returns an array.
Example #1:
Output:
[1, 2, 3, 4, 5, 6]
Example #2:
enu = { "gopal" => 10 , "geeks" => 20 }
enu.to_a
|
Output:
[["gopal", 10], ["geeks", 20]]