Assuming object
is a kind of NSObject
, the following if statements are equivalent, but which style should I use?
if (object) {
They are equivalent in the sense that they do the same thing. But I would argue that the second statement makes the code more readable. When a person reads the line, they will understand that it means "if object is not pointing to nothing."
Remember Knuth's dictum: a programming language is a way to deliver instructions to a machine in a human-readable form...
As you say, they're equivalent. Thus...
which style should I use?
Whichever one you want.