Skip to content

Instantly share code, notes, and snippets.

@skusunam
Created June 3, 2012 03:31
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 skusunam/2861719 to your computer and use it in GitHub Desktop.
Save skusunam/2861719 to your computer and use it in GitHub Desktop.
Flow Controls
if true == true
"we are ok"
if true != true then "panic"
#There is no ternary in Coffeescript
# (i > 0) ? "OK" : "Not OK"
if i > 0 then "OK" else "Not OK"
(or)
if i > 0 then "OK"
else "Not OK"
# suffixed if statement
alert "Hello Reds !!!" if heat < 5
# instead of negation (!) we can use "not" keyword
if not true then "panic"
# "unless" statement (looks like multi line is mandatory)
unless true
"panic"
# "is" statement which translates to "==="
if true is 1
"Type coercion fail!"
# "isnt" alternative to "is not"
if true isnt true
alert "Opposite day!"
if (true === true) {
"We're ok";
}
if (true !== true) {
"Panic";
}
if (1 > 0) {
"Ok";
} else {
"Y2K!";
}
# suffixed if statement
if (heat < 5) {
alert ("Hello Reds !!!");
}
# instead of negation (!) we can use "not" keyword
if (!true) {
"panic";
}
# "unless" statement (looks like multi line is mandatory)
if (!true) {
"panic";
}
# "is" statement which translates to "==="
if (true === 1) {
"Type coercion fail!";
}
# "isnt" alternative to "is not"
if (true !== true) {
alert ("Opposite day!");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment