Peter V Peter V - 23 days ago 6
CoffeeScript Question

call a function with no arguments in CoffeeScript

How do I call a function with no arguments in CoffeeScript without parens?

fun = -> alert "Boo!"


I have tried
fun.
and
(fun)

Answer
fun = -> alert "Boo!"
do fun

It is shorthand syntax for calling functions that are declared in-place.

someVar = do -> #some code...