From: Martin DeMello Date: 2007-02-15T16:14:17+09:00 Subject: Re: Justification for Array#join behaviour? On 2/15/07, Bertram Scharpf wrote: > > class Array > def deep_join sep > map { |x| > case x > when Array then x.deep_join sep > else x.to_s > end > }.join sep > end > end > > I don't look at this as a smart programming style actually. > > The object-oriented approach is to redefine `to_s'. Or class Object def join to_s end end module Enumerable def join "[" + inject {|a, e| a.join + ", " + e.join} + "]" end end class Array def join super end end class String def join self end end puts [1, 2, 3, [4, 5, [6, 7], 8]].join martin