Merge pull request #3970 from lydell/docs

Document a few undocumented things
This commit is contained in:
Michael Ficarra
2015-05-01 08:12:53 -07:00
3 changed files with 24 additions and 8 deletions

View File

@@ -3,7 +3,5 @@ quote = "A picture is a fact. -- #{ author }"
sentence = "#{ 22 / 7 } is a decent approximation of π"
direction = "top"
window.scrollBy "#{direction}": 100

View File

@@ -0,0 +1,4 @@
-7 % 5 == -2 # The remainder of 7 / 5
-7 %% 5 == 3 # n %% 5 is always between 0 and 4
tabs.selectTabAtIndex((tabs.currentIndex - count) %% tabs.length)

View File

@@ -531,6 +531,10 @@ Expressions
use <tt>by</tt>, for example:<br />
<tt>evens = (x for x in [0..10] by 2)</tt>
</p>
<p>
If you don't need the current iteration value you may omit it:<br />
<tt>browser.closeCurrentTab() for [0...count]</tt>
</p>
<p>
Comprehensions can also be used to iterate over the keys and values in
an object. Use <tt>of</tt> to signal comprehension over the properties of
@@ -658,8 +662,12 @@ Expressions
test for JavaScript object-key presence.
</p>
<p>
To simplify math expressions, <tt>**</tt> can be used for exponentiation, <tt>//</tt> performs integer division and <tt>%%</tt> provides true mathematical modulo.
To simplify math expressions, <tt>**</tt> can be used for exponentiation
and <tt>//</tt> performs integer division. <tt>%</tt> works just like in
JavaScript, while <tt>%%</tt> provides
<a href="http://en.wikipedia.org/wiki/Modulo_operation">“dividend dependent modulo”</a>:
</p>
<%= codeFor('modulo') %>
<p>
All together now:
</p>
@@ -827,6 +835,10 @@ Expressions
nonsense &mdash; a generator in CoffeeScript is simply a function that yields.
</p>
<%= codeFor('generators', 'ps.next().value') %>
<p>
<tt>yield*</tt> is called <tt>yield from</tt>, and <tt>yield return</tt>
may be used if you need to force a generator that doesn't yield.
</p>
<p>
<span id="embedded" class="bookmark"></span>
@@ -862,8 +874,9 @@ Expressions
<p>
<span id="try" class="bookmark"></span>
<b class="header">Try/Catch/Finally</b>
Try/catch statements are just about the same as JavaScript (although
they work as expressions).
Try/catch statements are just about the same as in JavaScript, with a few
additions: They work as expressions, and you may omit saving the error in
the catchor the entire catch itselfif you don't need it.
</p>
<%= codeFor('try') %>
@@ -882,7 +895,8 @@ Expressions
<b class="header">String Interpolation, Block Strings, and Block Comments</b>
Ruby-style string interpolation is included in CoffeeScript. Double-quoted
strings allow for interpolated values, using <tt>#{ ... }</tt>,
and single-quoted strings are literal.
and single-quoted strings are literal. You may even use interpolation in
object keys.
</p>
<%= codeFor('interpolation', 'sentence') %>
<p>