Created
August 28, 2015 12:23
-
-
Save chuck0523/02b97cfb511d80874158 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
# 継承 | |
log = (x) -> console.log x | |
class User | |
constructor : (@name) -> | |
hello : -> log "hello, #{@name}" | |
class AdminUser extends User | |
bob = new AdminUser "Bob" | |
log bob.name | |
bob.hello() | |
# Bob | |
# hello, Bob | |
# オーバーライドも可 | |
class SuperUser extends User | |
hello : -> | |
log "sudo " | |
super() | |
judy = new SuperUser "judy" | |
judy.hello() | |
# sudo | |
# hello, judy |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment