[haXe] Neko lastIndexOf seems wrong?
Asger Ottar Alstrup
asger at area9.dk
Thu Sep 21 14:50:10 CEST 2006
Hi,
I tried to use
var test = "c:\\great\\stuff";
trace("Found " + test.lastIndexOf("\\", 0));
in Neko. The result is surprisingly -1.
That prompted me to have a look at the code for the Neko version of
String.lastIndexOf, which reads:
public function lastIndexOf( str : String, pos ) {
untyped {
var last = -1;
if( pos == null )
pos = 0;
while( true ) {
var p = try __dollar__sfind(this.__s,last+1,str.__s) catch(
e : Dynamic ) null;
if( p == null || p > pos )
return last;
last = p;
}
return null;
}
}
The documentation for Neko sfind says:
int $sfind(src : string, pos : int, pat : string)
Return the first position starting at pos in src where pat was found.
Return null if not found. Error if pos is outside src bounds.
Am I wrong, or is this code is broken?
Regards,
Asger
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.motion-twin.com/pipermail/haxe/attachments/20060921/7fa80bec/attachment.htm
More information about the Haxe
mailing list