I\'ve just started using Coffeescript and the Coffeescript console, and Underscore. However, whenever I define a function, Coffeescript decides that _
means tha
The CoffeeScript REPL has this JavaScript at its heart:
try {
_ = global._;
returnValue = CoffeeScript["eval"]("_=(" + code + "\n)", {
filename: 'repl',
modulename: 'repl'
});
if (returnValue === void 0) {
global._ = _;
}
repl.output.write("" + (inspect(returnValue, false, 2, enableColours)) + "\n");
} catch (err) {
error(err);
}
So if the last command returned something then _
will be that something. I can't find any documentation about this though but searching for _
isn't a terribly productive activity. If you want to use Underscore.js in the CoffeeScript REPL, you'll have to call it something other than _
.
Thanks to Trevor Burnham (who wrote the book so I think we can trust him on this) we know that the CoffeeScript REPL uses _
as the last result to match the behavior of the node.js REPL:
REPL Features
[...]
The special variable_
(underscore) contains the result of the last expression.
Ruby's irb
does the same thing.