Else on its own line 11/17/14
Until a couple weeks ago, I always put my else
statements on the same line as the closing brace of the preceeding if
statement. This style has always seemed cleaner and more logical to me. I’d also guess that it’s the most common way of writing an if/else1.
However, after watching a few of Eliot Arntz’s Swift videos at Bitfountain2, I’ve converted to putting my else
statements on their own line.
Sure, we’re now ‘wasting’ an extra line, but we’ve gained the ability to comment out the entire else
statement quickly. It’s also easier to move the entire else
block around if you’re using a text editor like Vim that operates on entire lines.
-
Brent Simmons not withstanding. ↩
-
I’ve wanted to get into iOS development for years now. Maybe going through the Bitfountain videos will finally be the kick in the ass I need to make and ship an app. ↩