From: Jim Weirich Date: 2004-12-08T11:52:03+09:00 Subject: Re: [rcr] String#split behaves odd On Tuesday 07 December 2004 05:55 pm, Ryan Davis wrote: > To weigh in, I think the behavior of split should necessarily be > compared to splits in other languages, as long as our split acts in a > consistent and well behaved way. [...] Namely, anything > split (with a constant string/pattern) should be able to be joined back > to the original using that constant string. This is not currently the > case in ruby: > > irb(main):008:0> %w( aabb bbaa ).map do |s| s.split(/a/).join('a') == > s; end > => [true, false] %w( aabb bbaa ).map do |s| s.split(/a/,-1).join('a') == s; end # => [true, true] Don't drop trailing splits. -- -- Jim Weirich jim@weirichhouse.org http://onestepback.org ----------------------------------------------------------------- "Beware of bugs in the above code; I have only proved it correct, not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)