From: Austin Ziegler Date: 2004-12-10T03:49:58+09:00 Subject: Re: [rcr] String#split behaves odd On Fri, 10 Dec 2004 03:10:20 +0900, trans. (T. Onoma) wrote: > On Wednesday 08 December 2004 07:42 am, Austin Ziegler wrote: >> On Wed, 8 Dec 2004 15:56:01 +0900, trans. (T. Onoma) >> wrote: >>> On Wednesday 08 December 2004 12:00 am, Yukihiro Matsumoto wrote: >>>> I feel it might be difficult. Define the following: >>>> "abc\n".split("\n").join("\n") >>> >>> "abc\n".split("\n",-1).join("\n") >>> => "abc\n" >>> >>> Make default behavior -1. >> No. Most of the time, I don't actually *want* all the extra crap when I >> split. This change would break a lot of code silently. > Really? In all my code I either had to put the -1 in b/c I was getting > unexpected results (wasting many hours, btw!); or it didn't really matter > either way --empty strings usually end up in no-effect results. Really. I just did a quick audit of my publicly released code -- no checks to see what would be broken if I add -1 -- but NONE of my code uses split with -1, and I have ~45 split calls in said code. Are YOU going to volunteer to test all of my code (and everyone else's?) because you don't like adding the -1? > Might it break code? Sure. But a lot? I doubt it. In fact I suspect some of > those same programs might have edge cases that would break them for the lack > of the -1. *shrug* My code is written without the -1. If you want this default behaviour changed -- that's been in Ruby for quite a while -- then you take on the responsibility for testing all of the code out there. It is not clear that the existing behaviour is broken. -austin -- Austin Ziegler * halostatue@gmail.com * Alternate: austin@halostatue.ca