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:
@@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user