Skip to content

Instantly share code, notes, and snippets.

@jashkenas
Created February 10, 2012 16:29
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jashkenas/1790643 to your computer and use it in GitHub Desktop.
Save jashkenas/1790643 to your computer and use it in GitHub Desktop.
# Apart from the basic niceties of being able to leave off
# parens in clear calls...
print 10
alert "Hello #{name}"
# ... the reason why they're important to have in CoffeeScript
# is because it allows our "block" syntax (single function body
# passed as the final argument to a call) to play nicely with
# significant whitespace:
fs.readFile "config/options.json", (err, contents) ->
... work with file here.
# Writing the above without the ability to leave off the
# parens which would otherwise have to wrap the function body
# would defeat a large part of the purpose of significant
# whitespace in the first place.
@avdi
Copy link

avdi commented Feb 10, 2012

@jrus
Copy link

jrus commented Feb 12, 2012

Another way to avoid the inconsistency is of course:

($ 'some selector').click (e) ->
    ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment