mirror of
https://github.com/jashkenas/coffeescript.git
synced 2022-11-09 12:23:24 -05:00
docs for assignment-as-expression
This commit is contained in:
parent
adaae0ccae
commit
834442148b
21 changed files with 190 additions and 128 deletions
|
@ -1,20 +1,20 @@
|
|||
(function(){
|
||||
|
||||
var __a, __b, __c, __d, cubed_list, list, math, num, number, opposite_day, square;
|
||||
// Assignment:
|
||||
var number = 42;
|
||||
var opposite_day = true;
|
||||
number = 42;
|
||||
opposite_day = true;
|
||||
// Conditions:
|
||||
if (opposite_day) {
|
||||
number = -42;
|
||||
}
|
||||
// Functions:
|
||||
var square = function(x) {
|
||||
square = function(x) {
|
||||
return x * x;
|
||||
};
|
||||
// Arrays:
|
||||
var list = [1, 2, 3, 4, 5];
|
||||
list = [1, 2, 3, 4, 5];
|
||||
// Objects:
|
||||
var math = {
|
||||
math = {
|
||||
root: Math.sqrt,
|
||||
square: square,
|
||||
cube: function(x) {
|
||||
|
@ -22,11 +22,10 @@
|
|||
}
|
||||
};
|
||||
// Array comprehensions:
|
||||
var cubed_list;
|
||||
var __a = list;
|
||||
var __d = [];
|
||||
for (var __b=0, __c=__a.length; __b<__c; __b++) {
|
||||
var num = __a[__b];
|
||||
__a = list;
|
||||
__d = [];
|
||||
for (__b=0, __c=__a.length; __b<__c; __b++) {
|
||||
num = __a[__b];
|
||||
__d[__b] = math.cube(num);
|
||||
}
|
||||
cubed_list = __d;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue