Below you will see a small code snippet that contains scoped and deferred anonymous functions:
func scopedDefer() (x int) {
x--
defer func() { x += 10 }()
{
defer func() { x *= 2 }()
}
x--
return
}Please select the final value of x when the scopedDefer() function is completed.
Note that the
x variable is defined as a named return value of the scopedDefer() function; therefore the initial value of x is 0.