Per Ray's suggestion, this returns undefined, rather than null, if the object is not found

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@5004 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Tom Conkling
2008-04-17 19:14:42 +00:00
parent 855b4f27d4
commit 3b863e30fa
+3 -3
View File
@@ -120,15 +120,15 @@ public class ArrayUtil
/** /**
* Returns the first item in the array for which the predicate function returns true, or * Returns the first item in the array for which the predicate function returns true, or
* null if no such item was found. The predicate function should be of type: * undefined if no such item was found. The predicate function should be of type:
* function (element :*) :Boolean { } * function (element :*) :Boolean { }
* *
* @return the matching element, or null if no matching element was found. * @return the matching element, or undefined if no matching element was found.
*/ */
public static function findIf (arr :Array, predicate :Function) :* public static function findIf (arr :Array, predicate :Function) :*
{ {
var index :int = (arr != null ? indexIf(arr, predicate) : -1); var index :int = (arr != null ? indexIf(arr, predicate) : -1);
return (index >= 0 ? arr[index] : null); return (index >= 0 ? arr[index] : undefined);
} }
/** /**