Created
October 19, 2011 15:22
-
-
Save nakajima/1298615 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
coffee> if true then "OK" else "UH OH" | |
'OK' | |
coffee> if false then "OK" else "UH OH" | |
'UH OH' |
Any time! Though in general, I prefer
if something
foo = "OK"
else
foo = "oh no"
to
foo = if something then "OK" else "oh no"
I think there's too much going on with that one line.
Yeah, I was mainly looking for the preferred best practice. You're right, breaking it into lines seems like the way to go.
I respectfully disagree; think it stays fairly readable given the clauses of the if statement are simple, and 1 line instead of 4 is a big win in my book. But to each their own!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
<3 <3 <3 thanks++