Skip to content

Instantly share code, notes, and snippets.

@jrunning
Created June 30, 2014 15:43
Show Gist options
  • Save jrunning/f392fbedb2997de8860c to your computer and use it in GitHub Desktop.
Save jrunning/f392fbedb2997de8860c to your computer and use it in GitHub Desktop.
Weird CoffeeScript indentation gotcha

This CoffeeScript...

->
  return if true
  console.log "foo"

...compiles to...

(function() {
  if (true) {
    return;
  }
  return console.log("foo");
});

This CoffeeScript...

->
  return if true
    console.log "bar"

...yields...

(function() {
  if (true) {
    return console.log("halp");
  }
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment