$, = ", "
There's also another solution in there along with Yukihiro Matsumoto's response to both. It's somewhat annoying to always type .join(', ') when printing out an array, so I might start to use this, at least when using irb.
Thursday, August 26, 2010
Make Ruby Array to_s Make Comma-delimited Strings
If you want to_s when called to array to always output comma-delimited array values, try the following from a post by Ben Giddings (long ago in 2003):
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment