Created
August 18, 2011 11:14
-
-
Save melvynhills/1153858 to your computer and use it in GitHub Desktop.
Method types in CoffeeScript
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
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 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
simple and clear, well done