فهرست منبع

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

Justin Donaldson 9 سال پیش
والد
کامیت
f0948a38fa
1فایلهای تغییر یافته به همراه2 افزوده شده و 2 حذف شده
  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> {
 		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 [];
 
 		var ret = [];