Skip to content

Instantly share code, notes, and snippets.

@nakajima
Created October 19, 2011 15:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nakajima/1298615 to your computer and use it in GitHub Desktop.
Save nakajima/1298615 to your computer and use it in GitHub Desktop.
coffee> if true then "OK" else "UH OH"
'OK'
coffee> if false then "OK" else "UH OH"
'UH OH'
@patrickmoberg
Copy link

<3 <3 <3 thanks++

@nakajima
Copy link
Author

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.

@patrickmoberg
Copy link

Yeah, I was mainly looking for the preferred best practice. You're right, breaking it into lines seems like the way to go.

@goggin13
Copy link

goggin13 commented Nov 8, 2011

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