[haXe] Array.splice behaving strangely on Neko

Nicolas Cannasse ncannasse at motion-twin.com
Thu Sep 21 09:31:41 CEST 2006


> Hello list,
> 
>   I was playing with Array.splice for a while and found a strange
>   thing. According to the spec,
>     splice(beg, end) includes [beg] but not [end].
> 
>   This, for instance, means that
>     a.splice(0, a.length) is legal and same as a
> 
>   However, if I take an array:
>     [0, 1, 2].splice(1, 3) throws an exception
>     [0, 1, 2].splice(1, 2) returns [1, 2]
> 
>   which does not look right..

I think you mistake "slice" which takes [beg] and [end] with "splice"
which takes [beg] and [len]. Don't ask me why this is like that, haXe is
just trying to be AS/ES/JS compatible with these methods.

Nicolas



More information about the Haxe mailing list