Skip to content

Instantly share code, notes, and snippets.

@alsonkemp
Forked from madebysofa/gist:266191
Created January 1, 2010 18:29
Show Gist options
  • Save alsonkemp/267191 to your computer and use it in GitHub Desktop.
Save alsonkemp/267191 to your computer and use it in GitHub Desktop.
# 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