Is there a question here?
If I understand your assertion correctly, I disagree with it. The Camel book says 'If LIMIT is negative, it is treated as if an arbitrarily large LIMIT has been supplied'.
So the last two cases in your example are entirely consistent.
Cheers,
mildside | [reply] |
I agree with you there, I remember working on a script some years ago and this biting me in the ass. In particular, note the difference between split /:/, "A", -1 (1 field) and split /:/, "", -1 (0 fields).
So, you can consider it a bug — or a bad design desicion. Or, you can feel that this is the proper way to behave. I'm no sure either way. It most definitely is a corner case, and if you want it, it's best to treat a zero length string as a special case, returning (""), and have any other string be delt with by split. | [reply] [d/l] [select] |
This behavior is described in the documentation for split:
If LIMIT is specified and positive, it represents the maximum number of fields the EXPR will be split into, though the actual number of fields returned depends on the number of times PATTERN matches within EXPR. If LIMIT is unspecified or zero, trailing null fields are stripped (which potential users of pop would do well to remember). If LIMIT is negative, it is treated as if an arbitrarily large LIMIT had been specified. Note that splitting an EXPR that evaluates to the empty string always returns the empty list, regardless of the LIMIT specified.
| [reply] |