qwertyzw qwertyzw - 1 month ago 11
CoffeeScript Question

Coffeescript's Q.defer() then's call back

I've seen

defereed.then (arg) =>
function body


And

deferred.then (
(arg) =>
function body
)


Can someone explain the difference?

This is from https://github.com/gwomacks/php-debug/blob/master/lib/engines/dbgp/dbgp-instance.coffee

Answer

There is no difference. Parenthesis are optional in Coffeescript:

You don't need to use parentheses to invoke a function if you're passing arguments. The implicit call wraps forward to the end of the line or block expression.

console.log sys.inspect object → console.log(sys.inspect(object));