I’m aware of using syntax like this:
(something) ? TRUE : FALSE
But what if i want to return checking variable? For example:
if([myVar objectForKey:objectName])
return [myVar objectForKey:objectName]
else
return -1;
Is there a syntax like first line of code here that do that?
Of course i know that i can simply do something like:
([myVar objectForKey:objectName]) ? return [myVar objectForKey:objectName] : return -1;
But this is AFAIK very ugly solution
Off the top of my head I think this should work (EDIT: but see andyvn22’s answer re: return types):
As a general rule, though, you’re almost always better off using an easy to understand notation than one that is slightly more concise but cryptic.