Tuesday, October 21, 2008

Formatting arrays in Ruby

So i've been playing around some more with Ruby. The default formatting of arrays leaves something to be desired in my opinion. Here's what i use instead:

class Array
def to_s
'[' + collect{|x| x.to_s}.join(', ') + ']'
end
end

No comments: