Hi --

On Tue, 9 Jul 2002, Yukihiro Matsumoto wrote:

> Hi,
>
> In message "String#split converts string args to regexes -- ?"
>     on 02/07/09, David Alan Black <dblack / candle.superlink.net> writes:
>
> |Any insights on why #split does this?  I found it quite surprising
> |when I discovered it, and I don't know of anywhere where it's
> |documented as working this way.
>
> Insights?  It's inherited from Perl.  Try:
>
>   % perl -le 'print join(":", split(".b", "abcabc"))'
>   :c:c

But the distinction between 1-char and multi-char string arguments
doesn't come from Perl, I think, and that's the part I find so
unexpected.

> But if it turns out to be a bad inheritance (and I admit I'm starting
> to feeling so), I'm open to a new RCR.

Changing it would make a lot of documentation instantly up-to-date,
which is the opposite of what usually happens with language changes
:-)

I would certainly advocate making it consistent: split(/re/) or
split("string"), leaving the choice to the programmer and not doing
any automatic conversion of strings.


David

-- 
David Alan Black
home: dblack / candle.superlink.net
work: blackdav / shu.edu
Web:  http://pirate.shu.edu/~blackdav