Re: Bug in String's split method???



Yes I saw that part, but the part that throws me is the limit
parameter. Here are the docs on that. Not the asterisks.

The limit parameter controls the number of times the pattern is
applied and therefore affects the length of the resulting array. If the
limit n is greater than zero then the pattern will be applied at most n
- 1 times, the array's length will be no greater than n, and the
array's last entry will contain all input beyond the last matched
delimiter. If n is non-positive then the pattern will be applied as
many times as possible and the array can have any length. *If n is zero
then the pattern will be applied as many times as possible, the array
can have any length, and trailing empty strings will be discarded.*

------

I think that the poriton you emphasized "f the expression does not
match any part of the input then the resulting array has just one
element,
namely this string." and the portion I emphasized "If n is zero then
the pattern will be applied as many times as possible, the array can
have any length, and trailing empty strings will be discarded."
conflict with eachother in the case

"".split(",", 0);

The limit was zero so the empty trailing field should have been
discarded. I could read the docs both ways. The docs are ambiguous on
this feature.

.



Relevant Pages

  • Re: Arrays of zero length
    ... The minor strangeness is that when you allocate an array to zero size, ... saying something like that allocating an array makes it undefined ... In f77, zero-size was disallowed, ...
    (comp.lang.fortran)
  • Re: should every thing be zero indexed?
    ... Other families of languages count from 1. ... its number is zero: I always start counting at zero". ... > as a fundamental concept in both the definition of array indices and ... > for I in foo'range loop ...
    (comp.programming)
  • Re: Subset Sum problem (w/ limited scope)
    ... The "Subset Sum" problem (stated various ways depending on what you ... a subset of those integers that sums up to zero. ... Are there going to be duplicate values in your original array? ...
    (comp.lang.fortran)
  • Re: Subset Sum problem (w/ limited scope)
    ... The "Subset Sum" problem (stated various ways depending on what you ... a subset of those integers that sums up to zero. ... Are there going to be duplicate values in your original array? ...
    (comp.lang.fortran)
  • Re: addEvent - The late entry :)
    ... take any number of arguments and append them to an array. ... argument, which is fine on everything but Firefox, where it makes the ... 20 arguments Windows Safari 3 executes that expression in 48% of the ... and at zero arguments 47%. ...
    (comp.lang.javascript)