Thread: Curly brackets!
View Single Post
Old 05-06-2009, 02:16 PM   #13 (permalink)
Wildhoney
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
Wildhoney is on a distinguished road
Default

In your example, you really don't need that else for the return because it's going to happen irrespective of anything else. In those examples where it either is or isn't, then check for an is, and the isn't will be the default.

Think of it in binary terms, yes/no, true/false, 0/1. If you check for the yes (true, 1), then the no (false, 0) is the resulting value, and can be returned as such.

It's when you introduce more complicated conditionals that it requires more thinking on your behalf, such as with hexadecimal (base-16), and even our base-10 counting system. Anything other than base-2 (binary), where we only have the possibility of 2 outcomes, which is fundamentally how computers work (and many more things, too), and so tends to be used quite commonly in everyday life, and to keep the topic relevant, in programming also.

I don't think there is any such performance gain, it's personal preference for readability, really.
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote