Reputation: 759
I want to use do to call a function without parameters like so:
do someMethod
from experimenting it seems like I can also write:
total = 42
do total.toString
question, can I do this:
return do next if request.someField == 'ok'
instead of:
return next() if request.someField == 'ok'
Upvotes: 2
Views: 226
Reputation: 39223
The answer is yes.
I see you are asking about convention. The convention, AFAIK, is to use parentheses when there are no parameters: foo()
, and to use do when it's convenient to wrap a few variables in a closure:
for item, index in items
do (item, index) ->
// Do some stuff
Upvotes: 1