SPLIT Semantics

On Red Gitter, it was discussed "which of the following is 'correct'":

Red> split "" ","
== [""]

R3> split "" ","
== []

Rebolek thinks R3 is right. Boris says:

I don't think there's a correct answer, just choices. I prefer the Red version because:
it strictly follows the rule: `number-of-segments = 1 + number-of-delimiters", no exceptions, so it's easier to reason about

it should be able thus to preserve the type in case one wants to rejoin it later (that it doesn't is a bug, try split %"" ",")

So there's a couple of ways to look at it.

But I have a philosophy about these things where I want edge cases to be "noisy", because usually they require special handling. I might even say:

>> split "" ","
== ~null~  ; isotope
1 Like