let's say i have a simple function like that:
foo ->
User.findById someId, (err, user) ->
return "hello #{user.name}"
coffeescript translate it to that:
foo(function() {
return User.findById(someId, function(err, user) {
return "hello " + user.name;
});
});
so there are 2 returns here from some reason, but i just want to return the "hello" after the callback.
the only way i found not to return a function when i use it is by closing it with a return
(that is a weird workaround). so:
foo ->
User.findById someId, (err, user) ->
return "hello #{user.name}"
return
will translate into:
foo(function() {
User.findById(someId, function(err, user) {
return "hello " + user.name;
});
});
is there a better way to do that other than closing a function with a return
key?