coffeescript icon indicating copy to clipboard operation
coffeescript copied to clipboard

Using extends apart from class declaration

Open OnesimusUnbound opened this issue 15 years ago • 6 comments

I wonder if extends can be used apart from declaring class. The following code worked, through I doubt if extends should be used apart from class declaration.

A = 
    name: "John"

B = 
    age: 12

C = 
    description: "I love CoffeeScript"

D = A extends B extends C

for prop, value of D 
    console.log "#{prop} = #{value}"

OnesimusUnbound avatar Apr 02 '11 01:04 OnesimusUnbound

I'm interested to know if this is an official feature too.

erisdev avatar Apr 02 '11 03:04 erisdev

https://github.com/jashkenas/coffee-script/blob/1.0.1/src/grammar.coffee#L535

satyr avatar Apr 02 '11 03:04 satyr

Yes, as @satyr pointed out, this is already a part of the language. Closing.

michaelficarra avatar Apr 02 '11 03:04 michaelficarra

This doesn't appear to be documented anywhere but the grammar—might be a good move to add a line somewhere clarifying it. :)

erisdev avatar Apr 02 '11 19:04 erisdev

@erisdiscord: Yeah, good idea. Re-opening.

michaelficarra avatar Apr 02 '11 21:04 michaelficarra

It was only mentioned in a few words in the docs -- I've expanded the mention. Thanks for opening the issue.

jashkenas avatar Apr 27 '11 00:04 jashkenas