5 ms·
> I know CoffeeScript had some issues handling its certain attributes* > within its constructors Oh really? Do tell.
by jashkenas 13y ago
> I know CoffeeScript had some issues handling its certain attributes*
> within its constructors
Oh really? Do tell.
- solox3 13y agoclass a constructor: -> # conventionally logs 3 console.log @c class b extends a c = 3 new b() # logs undefined
- jashkenas 13y agoNot quite. Key-value properties use the colon syntax. Regular assignment is for local variables. Your "c" is a local variable within the class body of "b", and should absolutely not be visible from the constructor of "a". Here's the corrected version: class a constructor: -> console.log @c class b extends a c: 3 new b() # logs 3
- solox3 13y agoToday the whole office learned. Thanks a bunch, Jeremy!