Created
January 29, 2014 04:48
-
-
Save gkop/8681995 to your computer and use it in GitHub Desktop.
Dog class in coffee
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 Dog | |
age: -> | |
@human_age * 7.002 | |
my_dog = new Dog() | |
my_dog.human_age = 4.5 | |
my_dog.name = "Stewie" | |
my_dog.greeting = -> | |
"Woof! I'm #{this.name}" | |
jasons_dog = new Dog() | |
jasons_dog.human_age = 4 | |
jasons_dog.name = "Simba" | |
jasons_dog.greeting = -> | |
"Bow wow! My name's #{@name}" | |
for dog in [my_dog, jasons_dog] | |
console.log("#{dog.name} is #{dog.age()} years old. #{dog.greeting()}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment