This is a read-only archive of the Framer Community on Facebook.

What is Framer? Join the Community
Return to index
Brian Byle
Posted Jul 28 - Read on Facebook

Hello. I create a class with 2 properties, create an instance of the class, but 2nd is returned at "undefined". Why?

class Beer
constructor: (@name, @type) ->

myBeer = new Beer ("Epiphany", "DIPA")

print myBeer.name (returns "Epiphany")
print myBeer.type (returns "UNDEFINED")

Thx in advance, I'm new to classes!

3 Comments

Brian Byle

So if I made that change as you suggested, would I still pass the arguments like:

myBeer = new Beer ("Epiphany", "DIPA")

Brian Byle

What was confusing me, was if I used 1 parameter as:

class Beer
constructor: (@name)->

it worked fine. As soon as I added the 2nd param (@name, @type) it failed

Brian Byle

Thx Raf!

Read the entire post on Facebook