Is one of these a good way to make a once-invokable function?
As @UncleLaz stated in the comments, you're ignoring any arguments to the function. Also you don't memoize the return value of the function, and always just return true
. If you're really only caring about side effects, then that might not be a problem.
Is the extra do an issue or actually better?
In your case it's an issue. Check out the compiled javascript. Even if you corrected the indentation, it's not better since it's just unnecessarily introducing another scope.
A better, minimalistic way might be
once_maker = (f) ->
->
f?.apply this, arguments
f = null
(still not caring about the return value)