From: Josh Cheek Date: 2009-10-14T23:48:51+09:00 Subject: Re: converting object into array --000e0cd24e96bdf2b30475e642a2 Content-Type: text/plain; charset=ISO-8859-1 On Wed, Oct 14, 2009 at 9:14 AM, Paul Smith wrote: > On Wed, Oct 14, 2009 at 2:55 PM, Glenn Jackman wrote: > > At 2009-10-14 07:52AM, "Paul Smith" wrote: > >> > >> class User > >> def to_array > >> [] << @name << @age << @sex > >> end > >> end > > > > Curious: why that construct instead of: > > > > def to_array > > [@name, @age, @sex] > > end > > > > Probably go with to_a to follow conventions used by other code ie (1..5).to_a Original question isn't very clear, it sounds like OP might be wanting the brackets to be output as well, in which case you could use the inspect method on the array puts @user. to_a.inspect This is the same as p @user. to_a --000e0cd24e96bdf2b30475e642a2--