mirror of
https://github.com/jashkenas/coffeescript.git
synced 2022-11-09 12:23:24 -05:00
big commit -- adding back object comprehensions, using 'ino', versus 'in' for array comprehensions, fixing bug with dollar signs in identifiers
This commit is contained in:
parent
13fc8aea04
commit
902febb43a
18 changed files with 200 additions and 58 deletions
|
@ -1,5 +1,5 @@
|
|||
(function(){
|
||||
var __a, __b, __c, __d, __e, __f, __g, lunch;
|
||||
var __a, __b, __c, __d, __e, __f, __g, food, lunch, roid, roid2;
|
||||
// Eat lunch.
|
||||
lunch = (function() {
|
||||
__c = []; __a = ['toast', 'cheese', 'wine'];
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
(function(){
|
||||
var __a, __b, globals, name;
|
||||
var __a, __b, globals, name, property;
|
||||
// The first ten global properties.
|
||||
globals = ((function() {
|
||||
__b = []; __a = window;
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
try {
|
||||
return nonexistent / undefined;
|
||||
} catch (error) {
|
||||
return "The error is: " + error;
|
||||
return "Caught an error: " + error;
|
||||
}
|
||||
})());
|
||||
})();
|
18
documentation/js/object_comprehensions.js
Normal file
18
documentation/js/object_comprehensions.js
Normal file
|
@ -0,0 +1,18 @@
|
|||
(function(){
|
||||
var __a, __b, age, ages, child, years_old;
|
||||
years_old = {
|
||||
max: 10,
|
||||
ida: 9,
|
||||
tim: 11
|
||||
};
|
||||
ages = (function() {
|
||||
__b = []; __a = years_old;
|
||||
for (child in __a) {
|
||||
age = __a[child];
|
||||
if (__a.hasOwnProperty(child)) {
|
||||
__b.push(child + " is " + age);
|
||||
}
|
||||
}
|
||||
return __b;
|
||||
})();
|
||||
})();
|
|
@ -1,5 +1,5 @@
|
|||
(function(){
|
||||
var __a, __b, __c, cubed_list, list, math, number, opposite_day, race, square;
|
||||
var __a, __b, __c, cubed_list, list, math, num, number, opposite_day, race, square;
|
||||
// Assignment:
|
||||
number = 42;
|
||||
opposite_day = true;
|
||||
|
|
|
@ -1,8 +1,21 @@
|
|||
(function(){
|
||||
var __a, __b, __c, __d, dozen_eggs;
|
||||
__c = 0; __d = eggs.length;
|
||||
for (__b=0, i=__c; (__c <= __d ? i < __d : i > __d); (__c <= __d ? i += 12 : i -= 12), __b++) {
|
||||
dozen_eggs = eggs.slice(i, i + 12);
|
||||
deliver(new egg_carton(dozen));
|
||||
}
|
||||
var __a, __b, __c, __d, __e, countdown, egg_delivery, num;
|
||||
countdown = (function() {
|
||||
__b = []; __d = 10; __e = 1;
|
||||
for (__c=0, num=__d; (__d <= __e ? num <= __e : num >= __e); (__d <= __e ? num += 1 : num -= 1), __c++) {
|
||||
__b.push(num);
|
||||
}
|
||||
return __b;
|
||||
})();
|
||||
egg_delivery = function egg_delivery() {
|
||||
var __f, __g, __h, __i, __j, dozen_eggs, i;
|
||||
__g = []; __i = 0; __j = eggs.length;
|
||||
for (__h=0, i=__i; (__i <= __j ? i < __j : i > __j); (__i <= __j ? i += 12 : i -= 12), __h++) {
|
||||
__g.push((function() {
|
||||
dozen_eggs = eggs.slice(i, i + 12);
|
||||
return deliver(new egg_carton(dozen));
|
||||
})());
|
||||
}
|
||||
return __g;
|
||||
};
|
||||
})();
|
Loading…
Add table
Add a link
Reference in a new issue