perlmonger: (pete)
perlmonger ([personal profile] perlmonger) wrote2008-01-11 05:15 pm
Entry tags:

pass me another split, sergeant, this one's elfed

[Poll #1119627]

[ ETA that this is an abstract question, not an invitation for a language war, though go ahead and have one if you must ]

Some other response....

[identity profile] marko-carter.livejournal.com 2008-01-11 05:32 pm (UTC)(link)
An error. Heh.

[identity profile] purple-peril.livejournal.com 2008-01-11 05:36 pm (UTC)(link)
Two empty stringettes?

[identity profile] blue-condition.livejournal.com 2008-01-11 07:23 pm (UTC)(link)
Depends how fascist you're feeling. Quick'n'dirty script languages - an arrey of empty strings; neo-nazi - an exception.

I'm a Unix pragmatist though - SIGSEGV will do nicely ;)

[identity profile] ccomley.livejournal.com 2008-01-11 07:48 pm (UTC)(link)
Surely, it's two empty strings and an up quark?

[identity profile] quercus.livejournal.com 2008-01-12 12:25 am (UTC)(link)
The usual answer is an array of a single empty string, but I've never liked this and prefer the empty array.

Python naturally does both, as this is the most confusing behaviour possible. It only makes sense in Sanskrit, under particular phases of the moon. If you specify the toke, it returns an array of one empty string. If you _don't_ specify the token, then it does "default-based splitting" and looks for a normalised sequence of a set of the usual whitespace characters. BUT it also changes its empty string behavour so that it then returns an empty array instead!

[identity profile] spride.livejournal.com 2008-01-12 01:26 am (UTC)(link)
It should throw an exception which you should handle.