-
-
Save alsonkemp/267191 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
# standard constructor | |
Test1: constructor => | |
this.test = "test" | |
Test1.prototype.testFunction: => | |
print("It works!") | |
return null | |
t = new Test1() | |
t.testFunction() | |
# this constructor explicitly returns an array | |
Test2: constructor => | |
this.test = [1, 2, 3] | |
return this.test | |
Test2.prototype.testFunction: => | |
print("It works!") | |
t = new Test2() | |
print(t.length) | |
# this constructor implicitly returns this | |
Test3: constructor => | |
this.test = [1, 2, 3] | |
Test3.prototype.testFunction: => | |
print("It works!") | |
t = new Test3() | |
t.testFunction() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment