mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-05-03 03:00:14 -04:00
adding the long-ago-needed documentation for constructors with 'return this'
This commit is contained in:
@@ -611,6 +611,12 @@ coffee --print app/scripts/*.coffee > concatenation.js</pre>
|
||||
the immediate ancestor's method of the same name.
|
||||
</p>
|
||||
<%= code_for('super', true) %>
|
||||
<p>
|
||||
<b>A cautionary note:</b> JavaScript allows you to return a different value from
|
||||
a constructor function, ignoring the newly-created object. In CoffeeScript,
|
||||
it's best practice to always return <tt>this</tt> as the last line of a
|
||||
constructor, as seen above.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<span id="pattern_matching" class="bookmark"></span>
|
||||
|
||||
@@ -1279,6 +1279,12 @@ tom = new Horse("Tommy the Palomino");
|
||||
sam.move();
|
||||
tom.move();
|
||||
;'>run</button><br class='clear' /></div>
|
||||
<p>
|
||||
<b>A cautionary note:</b> JavaScript allows you to return a different value from
|
||||
a constructor function, ignoring the newly-created object. In CoffeeScript,
|
||||
it's best practice to always return <tt>this</tt> as the last line of a
|
||||
constructor, as seen above.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<span id="pattern_matching" class="bookmark"></span>
|
||||
|
||||
Reference in New Issue
Block a user