Browse Source

Lua: Apply fix for negative pos situations to negative end situations in Array.slice

Justin Donaldson 9 years ago
parent
commit
f0948a38fa
1 changed files with 2 additions and 2 deletions
  1. 2 2
      std/lua/_std/Array.hx

+ 2 - 2
std/lua/_std/Array.hx

@@ -71,8 +71,8 @@ class Array<T> {
 	}
 	}
 	public function slice( pos : Int, ?end : Int ) : Array<T> {
 	public function slice( pos : Int, ?end : Int ) : Array<T> {
 		if (end == null || end > length) end = length;
 		if (end == null || end > length) end = length;
-		else if (end < 0) end = length-(-end % length);
-		if (pos < 0) pos = (length -(-pos % length)) % length; // negative pos needs to be wrapped from the end, and mod according to array length
+		else if (end < 0) end = (length-(-end % length)) % length; // negative pos needs to be wrapped from the end, and mod according to array length
+		if (pos < 0) pos = (length -(-pos % length)) % length;  // and here
 		if (pos > end || pos > length) return [];
 		if (pos > end || pos > length) return [];
 
 
 		var ret = [];
 		var ret = [];