Created
April 27, 2010 19:16
-
-
Save andreyvit/381168 to your computer and use it in GitHub Desktop.
This file contains 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
# Tap as a language operator approach (say we call it ^, though it's a bad one) | |
# name ^ | |
# or expr ^ ( argname ) | |
# solves the "returning" problem | |
updateSize: (comp) -> | |
return null unless comp.isInDocument | |
size^: computeSize comp | |
$(comp.node).css { width: size.w; height: size.h } | |
# allows to quickly add and remove debugging code without breaking the line | |
foo: -> | |
code() | |
someCall().anotherCall() ^(res) .yetAnotherCall() | |
console.log "anotherCall returned ${res}" | |
moreCode() | |
# implicit arg naming example | |
foo: -> | |
code() | |
someCall().someField^.yetAnotherCall() | |
console.log "someField was ${someField}" | |
moreCode() | |
# explicit arg naming example | |
updateSize: (comp) -> | |
return null unless comp.isInDocument | |
size ^(computedSize): computeSize comp | |
$(comp.node).css { width: computedSize.w; height: computedSize.h } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment