Search code examples
coffeescript

Calling 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)


Solution

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

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

    someVar = do -> #some code...