mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-01-14 17:27:59 -05:00
added the ability to super()
This commit is contained in:
@@ -128,4 +128,12 @@ three_to_six: zero_to_nine[3, 6]
|
||||
# Multiline strings with inner quotes.
|
||||
story: "Lorem ipsum dolor \"sit\" amet, consectetuer adipiscing elit,
|
||||
sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna
|
||||
aliquam erat volutpat. Ut wisi enim ad."
|
||||
aliquam erat volutpat. Ut wisi enim ad."
|
||||
|
||||
# Calling super from an overridden method.
|
||||
Greeter: => . # Create the parent object.
|
||||
Greeter.prototype.hello: name => alert('Hello ' + name). # Define a "hello" method.
|
||||
Exclaimer: name => this.name: name. # Create the child object.
|
||||
Exclaimer.prototype: new Greeter() # Set the child to inherit from the parent.
|
||||
Exclaimer.prototype.hello: => super(this.name + "!"). # The child's "hello" calls the parent's via "super".
|
||||
(new Exclaimer('Bob')).hello() # Run it.
|
||||
|
||||
Reference in New Issue
Block a user