add firstObject method to CPArray

This commit is contained in:
Klaas Pieter Annema committed 2011-03-28 13:14:25 +02:00
1 parent 65ce93ce42
commit 42c60913c6
1 file changed
+14 -1
+14 -1
View File
@@ -205,7 +205,20 @@ var concat = Array.prototype.concat,
}
/*!
Returns the last object in the array. If the array is empty, returns \c nil/
Returns the first object in the array. If the array is empty, returns \c nil
*/
- (id)firstObject
{
var count = [self count];
if (count > 0)
return [self objectAtIndex:0];
return nil;
}
/*!
Returns the last object in the array. If the array is empty, returns \c nil
*/
- (id)lastObject
{