Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# 継承
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