mirror of
https://github.com/jashkenas/coffeescript.git
synced 2022-11-09 12:23:24 -05:00
subliminally promoting the use of interpolation in the documentation
This commit is contained in:
parent
6f64fc266d
commit
d3e809da38
9 changed files with 9 additions and 11 deletions
|
@ -8,4 +8,4 @@ if car.speed < limit then accelerate()
|
||||||
|
|
||||||
winner = yes if pick in [47, 92, 13]
|
winner = yes if pick in [47, 92, 13]
|
||||||
|
|
||||||
print inspect "My name is " + @name
|
print inspect "My name is #{@name}"
|
||||||
|
|
|
@ -2,7 +2,7 @@ class Animal
|
||||||
constructor: (@name) ->
|
constructor: (@name) ->
|
||||||
|
|
||||||
move: (meters) ->
|
move: (meters) ->
|
||||||
alert @name + " moved " + meters + "m."
|
alert @name + " moved #{meters}m."
|
||||||
|
|
||||||
class Snake extends Animal
|
class Snake extends Animal
|
||||||
move: ->
|
move: ->
|
||||||
|
|
|
@ -2,6 +2,6 @@ alert(
|
||||||
try
|
try
|
||||||
nonexistent / undefined
|
nonexistent / undefined
|
||||||
catch error
|
catch error
|
||||||
"And the error is ... " + error
|
"And the error is ... #{error}"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
yearsOld = max: 10, ida: 9, tim: 11
|
yearsOld = max: 10, ida: 9, tim: 11
|
||||||
|
|
||||||
ages = for child, age of yearsOld
|
ages = for child, age of yearsOld
|
||||||
child + " is " + age
|
"#{child} is #{age}"
|
||||||
|
|
|
@ -6,5 +6,5 @@ if this.studyingEconomics
|
||||||
# Nursery Rhyme
|
# Nursery Rhyme
|
||||||
num = 6
|
num = 6
|
||||||
lyrics = while num -= 1
|
lyrics = while num -= 1
|
||||||
num + " little monkeys, jumping on the bed.
|
"#{num} little monkeys, jumping on the bed.
|
||||||
One fell out and bumped his head."
|
One fell out and bumped his head."
|
||||||
|
|
|
@ -12,7 +12,7 @@ Animal = (function() {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
Animal.prototype.move = function(meters) {
|
Animal.prototype.move = function(meters) {
|
||||||
return alert(this.name + " moved " + meters + "m.");
|
return alert(this.name + (" moved " + meters + "m."));
|
||||||
};
|
};
|
||||||
return Animal;
|
return Animal;
|
||||||
})();
|
})();
|
||||||
|
|
|
@ -2,9 +2,7 @@ var footprints, solipsism;
|
||||||
if ((typeof mind !== "undefined" && mind !== null) && !(typeof world !== "undefined" && world !== null)) {
|
if ((typeof mind !== "undefined" && mind !== null) && !(typeof world !== "undefined" && world !== null)) {
|
||||||
solipsism = true;
|
solipsism = true;
|
||||||
}
|
}
|
||||||
if (typeof speed !== "undefined" && speed !== null) {
|
if (typeof speed === "undefined" || speed === null) {
|
||||||
speed;
|
|
||||||
} else {
|
|
||||||
speed = 75;
|
speed = 75;
|
||||||
};
|
};
|
||||||
footprints = typeof yeti !== "undefined" && yeti !== null ? yeti : "bear";
|
footprints = typeof yeti !== "undefined" && yeti !== null ? yeti : "bear";
|
|
@ -9,7 +9,7 @@ ages = (function() {
|
||||||
_results = [];
|
_results = [];
|
||||||
for (child in yearsOld) {
|
for (child in yearsOld) {
|
||||||
age = yearsOld[child];
|
age = yearsOld[child];
|
||||||
_results.push(child + " is " + age);
|
_results.push("" + child + " is " + age);
|
||||||
}
|
}
|
||||||
return _results;
|
return _results;
|
||||||
})();
|
})();
|
|
@ -12,7 +12,7 @@ lyrics = (function() {
|
||||||
var _results;
|
var _results;
|
||||||
_results = [];
|
_results = [];
|
||||||
while (num -= 1) {
|
while (num -= 1) {
|
||||||
_results.push(num + " little monkeys, jumping on the bed. One fell out and bumped his head.");
|
_results.push("" + num + " little monkeys, jumping on the bed. One fell out and bumped his head.");
|
||||||
}
|
}
|
||||||
return _results;
|
return _results;
|
||||||
})();
|
})();
|
Loading…
Add table
Add a link
Reference in a new issue