Skip to content

Instantly share code, notes, and snippets.

@andreyvit
Created April 27, 2010 19:16
Show Gist options
  • Save andreyvit/381168 to your computer and use it in GitHub Desktop.
Save andreyvit/381168 to your computer and use it in GitHub Desktop.
# 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