Instantly share code, notes, and snippets.
This prints 2.
Problem: if defer() runs after 1 is returned, changing ret var after return 1 is returned, main() should print 1..
return doesn't actually return a value, it just ends the function's regular execution and sets the return values. those values can still be changed by a deferred function call, as your code demonstrates.