Created
November 24, 2012 07:52
-
-
Save jay3sh/4138819 to your computer and use it in GitHub Desktop.
Switch-To-Coffeescript-Code-Snippets-2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Simple dictionary | |
point1 = x:1, y:3 | |
# For nested dictionaries | |
point2 = | |
x:1 | |
y:3 | |
attributes : | |
weight : 3 | |
label : 'A' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
point1 = { | |
x: 1, | |
y: 3 | |
}; | |
point2 = { | |
x: 1, | |
y: 3, | |
attributes: { | |
weight: 3, | |
label: 'A' | |
} | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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