From: Robert Dober Date: 2007-01-03T20:11:26+09:00 Subject: Re: Mini-RCR: Extra Argument for Array#join ------=_Part_141276_6675259.1167822685119 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline I got so taken away by optimizing, I missed my point! I feel that #join should be left alone, if a more powerful String# is to be needed maybe it would be better to call it than I feel too that having a prefix or postfix join available. A *strange* syntax would be possible (that's why it is not good, but I love it) def sep=$,, joins={} list = %{Something blue smth new smth borrowed} list.something( ', ' -2 => "and" ) => "Something, blue, smth, new, smth and borrowed" list.something( ', ' 0 => "{", -1 => "}" ) => "{Something, blue, smth, new, smth, borrowed}" now that is nonesense of course and might not work in 1.9/2.0??? let us be reasonable list.something(:sep => ", ", :odd => "") => "Something blue, smth new, smth borrowed" list.something(:sep => ", ", :odd => "", :last_even => "and" ) => "Something blue, smth new and smth borrowed" and in full form we would have (0..9).something( :pre => "<", :suff => ">", :even => "_", :odd => "-", :index => [5, "*"] ) => "<0-1_2-3_4*5_6-7_8-9>" That all still might be nonsense/bloat but I have gone to extremes to show why I think it would not be String#join anymore and thus should not be called String#join If OTOH a majority thinks enhancing String#join, what about a block enhancement list.join do |ele, index| (index % 2).zero? ? : "," ? "*" # might be nice to change sep on value of ele too. end cheers Robert -- "The real romance is out ahead and yet to come. The computer revolution hasn't started yet. Don't be misled by the enormous flow of money into bad defacto standards for unsophisticated buyers using poor adaptations of incomplete ideas." - Alan Kay ------=_Part_141276_6675259.1167822685119--