Skip to content

Instantly share code, notes, and snippets.

@jay3sh
Created November 24, 2012 07:52
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 jay3sh/4138819 to your computer and use it in GitHub Desktop.
Save jay3sh/4138819 to your computer and use it in GitHub Desktop.
Switch-To-Coffeescript-Code-Snippets-2
# While invoking a function you don't have to put the arguments in parenthesis.
# Instead of writing
console.log(message)
# You can write
console.log message
# Although this is convenient, it can be confusing for nested function calls
foo bar 2,3
# is equivalent to
foo(bar(2,3))
# Also you cannot skip parenthesis, if you are invoking a function without
# any arguments.
foo bar
# is equivalent to
foo(bar)
# and not
foo(bar())
# Simple dictionary
point1 = x:1, y:3
# For nested dictionaries
point2 =
x:1
y:3
attributes :
weight : 3
label : 'A'
point1 = {
x: 1,
y: 3
};
point2 = {
x: 1,
y: 3,
attributes: {
weight: 3,
label: 'A'
}
};
# Will compile successfully
if x is 23 and \
y is 34
foo(x)
# Will throw compiler error - note the indent
if x is 23 and \
y is 34
foo(x)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment