method

to_a

v1_8_7_330 - Show latest stable - Class: Object
to_a()
public

Returns an array representation of obj. For objects of class Object and others that don’t explicitly override the method, the return value is an array containing self. However, this latter behavior will soon be obsolete.

self.to_a       #=> -:1: warning: default `to_a' will be obsolete
"hello".to_a    #=> ["hello"]
Time.new.to_a   #=> [39, 54, 8, 9, 4, 2003, 3, 99, true, "CDT"]

1Note

Where did this go?

tobico · Feb 25, 2013

For Ruby 1.9 and later, use Kernel#Array to get this functionality.