2 ms·
We may have different definitions of 'temporary variable', but you don't need what I would think of as a temporary variable to make a self-calling closure:
by foldr 2y ago
We may have different definitions of 'temporary variable', but you don't need what I would think of as a temporary variable to make a self-calling closure:
toCapture := 99
var myClosure func() int
myClosure = func() int { return myClosure() + toCapture } // nonsense
myClosure()
It would be nice if Go would just allow the use of function definition syntax inside functions, though. Seems like a small and non-breaking change that could easily be made.