Skip to content

Instantly share code, notes, and snippets.

@mvolkmann
Created September 17, 2011 00:11
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 mvolkmann/1223437 to your computer and use it in GitHub Desktop.
Save mvolkmann/1223437 to your computer and use it in GitHub Desktop.
CoffeeScript indentation
a = b = c = 0
# This works.
# Note how the 2nd line is indented so "b" in 2nd line
# is in the same column as "a" in 1st line.
if a is b and
b is c
console.log 'works'
# This also works, but is ugly.
if a is b and
b is c
console.log 'works'
# This doesn't work because the "if" line needs some indication that
# the expression continues on the next line ... like ending with "and".
# Adding parens around the expression apparently isn't enough.
###
if (a is b
and b is c)
console.log 'works'
###
function1 = (p1, p2, p3, p4) -> console.log 'in function1'
function2 = (p1, p2, p3) -> console.log 'in function2'
# This works if the 2nd and 3rd lines have the same indentation.
# No other indentation of the 3rd line seems to work.
function1 this,
function2("doesn't",
"work"),
"sorry"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment