· The return value is fetched from each branch of execution · Return early from a function body by using an explicit return · Variable declarations are at the top of the scope, so assignment can be used within expressions, even for variables that have not been seen before · Statements, when used as part of an ex- pression, are converted into expressions with a closure wrapper. This allows as- signment of the result of a comprehen- sion to a variable · The following are not expressions: break, continue, and return Operators and Aliases · CoffeeScript compiles == into ===, and != into !==. There is no equivalent to the JavaScript == operator · The alias is is equivalent to ===, and isnt corresponds to !== · Logical operator aliases: and is &&, or is || and not is an alias for ! · In while, if/else and switch/when statements the then keyword can be used to keep the body on the same line · Alias for boolean true is on and yes (as in YAML) · Alias for boolean false is off and no · For single-line statements, unless can be used as the inverse of if · Use @property or @method instead of this.something · Use in to test for array presence · Use of to test for object-key presence Existential Operator · Use the existential operator ? to check if a variable exists. ? returns true unless a variable is null or undefined · Use ?= for safer conditional assignment than ||= with numbers or strings · The accessor variant of the existential operator ?. can be used to soak up null references in a chain of properties · Use ?. instead of the dot accessor . in cases where the base value may be null or undefined. If all of the properties ex- ist then the expected result is returned, if the chain is broken, then undefined is returned instead Classes, Inheritance, and Super · Object orientation as in most other ob- ject oriented languages · The class structure allows to name the class, set the superclass with extends, assign prototypal properties, and define a constructor, in a single assignable expression · Constructor functions are named as the class name, to support reflection · Lower level operators: The extends operator helps with proper prototype setup. :: gives access to an object’s prototype. super() calls the immediate ancestor’s method of the same name · A class definition is a block of exe- cutable code, which may be used for meta programming. · In the context of a class definition, this is the class object itself (the constructor function), so static properties can be assigned by using @property: value, and functions de- fined in parent classes can be called with: @inheritedMethodName() Destructuring Assignment · To make extracting values from com- plex arrays and objects convenient, CoffeeScript implements destructuring assignment · When assigning an array or object lit- eral to a value, CoffeeScript breaks up and matches both sides against each other, assigning the values on the right to the variables on the left · The simplest case is parallel assignment [a,b] = [b,a] · It can be used with functions that return multiple values · It can be used with any depth of array and object nesting to get deeply nested properties and can be combined with splats Function binding · The fat arrow => can be used to define a function and bind it to the current value of this · This is helpful when using callback- based libraries, for creating iterator functions to pass to each or event- handler functions to use with bind · Functions created with => are able to ac- cess properties of the this where they are defined Switch/When/Else · The switch statement do not need a break after every case · A switch is a returnable, assignable ex- pression · The format is: switch condition, when clauses, else the default case · Multiple values, comma separated, can be given for each when clause. If any of the values match, the clause runs String Interpolation, Heredocs, and Block Comments · Single-quoted strings are literal. Use backslash for escape characters · Double-quoted strings allow for inter- polated values, using #{ ... } · Multiline strings are allowed · A heredoc ''' can be used for formatted or indentation-sensitive text (or to avoid escaping quotes and apostrophes) · The indentation level that begins a here- doc is maintained throughout, so the text can be aligned with the body of the code · Double-quoted heredocs """ allow for interpolation · Block comments ### are similar to heredocs, and are preserved in the gen- erated code Extended Regular Expressions · Extended regular expressions are de- limited by /// and are similar to here- docs and block comments. · They ignore internal whitespace and can contain comments Aliases and : && or : || not : ! is : == isnt : != yes : true no : false on : true off : false Miscellaneous · Twitter comments to @autotelicum http://autotelicum.github.com/Smooth-CoffeeScript/