Skip to content

Instantly share code, notes, and snippets.

@melvynhills
Created August 18, 2011 11:14
Show Gist options
  • Save melvynhills/1153858 to your computer and use it in GitHub Desktop.
Save melvynhills/1153858 to your computer and use it in GitHub Desktop.
Method types in CoffeeScript
class Foo
privateMethod = ->
console.log "privateMethod"
publicMethod: ->
console.log "publicMethod"
privateMethod()
@staticMethod: ->
console.log "staticMethod"
class Bar extends Foo
tryFunction = (func) ->
try
func()
catch error
console.error error.message
console.log "Foo"
tryFunction Foo.staticMethod
tryFunction new Foo().privateMethod
tryFunction new Foo().publicMethod
console.log "---"
console.log "Bar"
tryFunction Bar.staticMethod
tryFunction new Bar().privateMethod
tryFunction new Bar().publicMethod
@arboleya
Copy link

simple and clear, well done

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