([NSArray -lastObject]): Don't assert count; just return nil if it's

empty.
([NSMutableArray -removeLastObject]): Don't assert count; raise
NSRangeError if it's empty.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@1314 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Andrew McCallum 1996-03-30 23:00:27 +00:00
parent 6298e0f17a
commit 82eb5732bd

View file

@ -294,8 +294,9 @@ static Class NSMutableArray_concrete_class;
- lastObject
{
int count = [self count];
assert(count); /* xxx should raise an NSException instead */
return [self objectAtIndex:count-1];
if (count == 0)
return nil;
return [self objectAtIndex: count-1];
}
- (void) makeObjectsPerform: (SEL)aSelector
@ -495,7 +496,9 @@ static Class NSMutableArray_concrete_class;
- (void) removeLastObject
{
int count = [self count];
assert(count); /* xxx should raise an NSException instead */
if (count == 0)
[NSException raise: NSRangeException
format: @"Trying to remove from an empty array."];
[self removeObjectAtIndex:count-1];
}