Reputation: 6267
I was poking around trying to figure a good way to do var
, and here's one.. is this intentionally in cs
, because it's not documented?
me=;
fetchUser()
.then((_me) =>
me = _me
fetchFriend()
)
.then((_you) =>
me.friend(_you)
)
.then(done)
.otherwise(=>
console.log ':('
)
compiles correctly to
var me;
me = fetchUser().then((function(_this) {
return function(_me) {
me = _me;
return fetchFriend();
};
})(this)).then((function(_this) {
return function(_you) {
return me.friend(_you);
};
})(this)).then(done).otherwise((function(_this) {
return function() {
return console.log(':(');
};
})(this));
I wouldn't expect me = fetchUser()
either, but I didn't see that before
https://github.com/jashkenas/coffee-script/issues/3098
Upvotes: 1
Views: 34
Reputation: 237080
I think it's just a quirk of the parser. The normal way variables are declared in order to establish scoping is just by defining them with some default value (e.g. null).
Upvotes: 1