samedi 3 janvier 2015

if statment in objective-c

Can someone please help to explain the syntax of the following code for me? It meant to "return ? if _suit is nil, and return a corresponding string in an array if _suit is not nil.



- (NSString *)suit
{
return _suit ? _suit : @"?";
}


Is it equivalent to the following code?



if (!_suit){
return @"?";
}else{
return ?
}

Aucun commentaire:

Enregistrer un commentaire