سؤال

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' 
هل كانت مفيدة؟

المحلول

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
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top