Skip to content
satyr edited this page Mar 23, 2011 · 27 revisions
$ coffee -v
CoffeeScript version 1.1.0-pre

unmatched unindentations

$ coffee -se
if 0
  if 0
    console.log 1
   console.log  2
  console.log   3

3

cf. $ python <<_ > if 0: > if 0: > print(1) > print(2) > print(3) > _ File "", line 4 print(2) ^ IndentationError: unindent does not match any outer indentation level

implicit object quirks

$ coffee -ne 'f a: b, 2 * c'
Error: Parse error on line 1: Unexpected 'MATH'

$ coffee -bsp
a: b: c
d: e

({
  a: {
    b: c,
    d: e
  }
});

global leak

$ coffee -pe 'a ?= 1'
(function() {
  typeof a != "undefined" && a !== null ? a : a = 1;
}).call(this);

(un)nested comprehensions

$ coffee -bse
console.log do ->
  for i in [1..2]
    for j in [3..4]
      i + j

[ [ 4, 5 ], [ 5, 6 ] ]

cf. js> uneval([i+j for each(i in [1,2]) for each(j in [3,4])]) [4, 5, 5, 6]

Clone this wiki locally