By Developers, For Developers

Historical errata for CoffeeScript

PDF PgPaper PgTypeDescriptionFixed onComments
111TYPO

x ?= y x = y unless x? if (typeof x != ‘undefined’ && x !== null) {x=y}

If I understand well the ?= operator, the condition in the javascript column is inversed. It should be:

if (typeof x 'undefined' || x = null) {x=y}

2011-05-10D'oh, nicely spotted.
34SUGGEST

On question 6, I believe that

“@x refers to variable that obeys context rules”

should be

“@x refers to a variable that obeys context rules”

2011-05-10
60ERROR

In the Tribble.coffee example, the method `Tribble.makeTrouble()` doesn’t return output. When compiled to JavaScript, the `for` loop doesn’t run in the proper context (which should be `this`).

2011-05-10Thanks for spotting this. This was a bug introduced in CoffeeScript 1.1.0, and it's been fixed in the just-released 1.1.1.
42SUGGEST

“No scope for ‘for’”
Is it worth noting that in the butler example if no entity in murderMysteryCharacters has the occupation of ‘butler’ that the last entity in the collection gets blamed?

2011-05-13The thing is that hash order isn't consistent across all JS implementations, so using the last index of a `for..of` loop isn't a good pattern to promote... so the example is intended only for use in scenarios where the butler only did it (and, for that matter, in which there's only one butler).
43TYPO

«CoffeeScript’s of is equivalent to JavaScript’s ’in.»
There’s an extra apostrophe, or single quote, before “in”.

2011-05-13
43SUGGEST

«Think of it this way: Values live in an object, while you have keys of an object.»

The typeface/style of ‘in’ and ‘of’ made me think you were alluding to the operators of the same name, when I believe this was supposed to indicate emphasis.

If we were to draw a parallel with the operators, should we not be encouraged to think that values live ‘in’ an array?

Add a pinch of extra confusion when the sentence preceding that quote states that “CoffeeScript’s of is equivalent to JavaScript’s in”; however, JavaScript’s “in” returns keys, not values.

My suggestion is to display ‘in’ and ‘of’ in italics.

2011-05-13
43SUGGEST

«of and in lead double-lives as operators»

I thought this worthy of a simple example block; I almost skimmed over the paragraph.

murderMysteryCharacters =
‘Colonel Mustard’: ‘colonel’
‘Professor Plum’: ‘professor’
fruits = [ ‘apple’, ‘banana’, ‘cherry’, ‘tomato’ ]
vegetables = [ ‘asparagus’, ‘broccoli’, ‘carrot’, ‘turnips’ ]
console.log ‘Professor Plum’ of murderMysteryCharacters
console.log ‘Ms. Priss’ of murderMysteryCharacters
console.log ‘apple’ in fruits
console.log ‘tomato’ in vegetables

2011-05-13You're absolutely right that an example is needed there. I borrowed your fruit example.
93ERROR

The ‘message.match’ regex triggers syntax highlighting that extends too far; the ‘extend = (a, others…)’ block’s highlighting is wrong.

2011-05-25Definitely nasty formatting: Everything starting with a `/` is assumed to be a regex, and closing `/`s are ignored. Should be fixed soon.
14ERROR

I believe it should be a
console.log greeting ‘arguments’

2011-05-17Hmm, you're right... I realize I'm not entirely consistent about using `console.log` in the book (unnecessary if you're on the REPL in many cases, but not all). I don't think that's a big deal as long as the inconsistency isn't too glaring. But since the example immediately preceding that one used `console.log`, it is an odd discrepancy.
45TYPO

Clone of #47072 — other places where example style is off:
«when isInteger(960 / num))»
“/ num))” appear in italics

2011-05-25Thanks, we're working on it.
62TYPO

Clone of #47072 — other places where example style is off:
«radius: -> @width / 2»
The text at “/ 2” until the end of the sample block appears in italics

2011-05-25Thanks, we're working on it.
45TYPO

«So what’s the value of a loop? An array of the the loop’s iteration values, naturally.»
“the the”

2011-05-25Thanks for catching this.
4SUGGEST

You might want to let us know how to quit out of the Node console… ‘quit’, ‘end’, ‘exit’ all produced errors.

2011-05-25You could use `process.exit()`, but Ctrl+C (the standard Unix kill shortcut) should work just fine. I'll mention that when I introduce the node console.
61TYPO

“prooperties” should be “properties”.

2011-05-25Ouch, thanks for catching that one.
68SUGGEST

For exercise 4.7.1, I think it might be better to use global instead of exports - I found it confusing when I typed the code into a file chapter4.coffee, ran it, and got “ReferenceError: aphorism is not defined”.

2011-05-25You're quite right! Use of the `global` object is usually frowned on, but `exports` doesn't make sense here.
75TYPO

“That means that the while the parentheses…” should be “That means that while the parentheses…”.

2011-05-25Thanks for catching this.
82TYPO

“Here’s how the game looks when it all comes together:” should refere to Figure 5 which is on the next page.

2011-05-25Thanks, I'll add a link there.
61TYPO

You wrote “prooperties” instead of “properties” at the fourth line before the end of the page.

2011-05-25Duplicate of #47095, will be fixed in the next beta release.
31-32SUGGEST

on page 31, why not use this as the definition for the function inRange

inRange = (x, y) ->
0 <= x <= GRID_SIZE and 0 <= y <= GRID_SIZE

Then on the top of page 32 you can get rid of the (–1)s to make the old inRange work:

else if not inRange x, y #was x-1, y-1 before
console.log “Each coordinate must be between 1 and #{GRID_SIZE}”

Thanks. I’m enjoying the book so far,
Tim

2011-06-04I'd rather leave it as-is. There's method to the madness: While the input logic has @x@ and @y@ go from 1 to @GRID_SIZE@, all the "backend" logic keeps the numbers 0-indexed. In the later chapters, when the game moves to the browser, the human-friendly number formatting is dropped entirely, @x@ and @y@ are consistently 0-indexed, and the @inRange@ function remains the same.
83TYPO

“prooperties” is misspelled.

2011-06-01Dupe, already fixed. New beta version is coming very soon.
84TYPO

The code coloring is off, when talking about class inheritance of the shapes.

2011-06-04Could you be more specific? It's fine in my local build.
2TYPO

The ‘s’ is missing in ‘Windows’ where it reads “While the Node team is working to improve their support for Window”

2011-06-01
7SUGGEST

This is specific to the Mobi version of the book.

It reads “See the sidebar … for an explanation …” but there is no “sidebar”. The explanation is just inline and follows immediately. There’s no space for a sidebar on an eReader :)

2011-06-04Hmm, this one's out of my hands... PragProg's compiler actually inserts the words "the sidebar" based on the markup of the link I add. I'll let them know about this.
32ERROR

“Well, console.log returns null, which gets coerced to false
by condition checks” -> Should that actually be “console.log returns undefined”?

coffee> console.log console.log “test”
test
undefined

2011-06-04Thanks, fixed.
50TYPO

“those inRange checks ensure that both ends a potential
word are within the grid” should be “both ends of a potential word”

2011-06-04
71TYPO

“and Resig has become of the world’s most famous programmers” should be “and Resig has become one of the world’s most famous programmers”

2011-06-04Thanks! Fixed.
77ERROR

Everywhere I’ve read about in browser compilation using coffee-script.js says that you should include it after any coffeescript. You’re including it before the coffeescript files, is this a mistake?

2011-06-04It doesn't matter. @coffee-script.js@ waits until the document has fully loaded before looking for