3 ms·
In go, you can just inline a lambda to force defer to adhere to any scope that you the programmer decide upon. func(){ Code for lock and deferred unlock here
by fxtentacle 6y ago
In go, you can just inline a lambda to force defer to adhere to any scope that you the programmer decide upon.
func(){
Code for lock and deferred unlock here
}()
- knorker 6y agoWell, no you can't, because that leaves no way to directly return from the function. Hence my example where the lambda has to return an error, and the loop has to check for the error. It's A LOT of boilerplate. Edit: Actually now I don't know what you mean. You clearly replied to my comment that gave a clear example with a return from within the lambda, so what did you think that I didn't know? You took my example and removed extremely commonly needed functionality. So… huh?