Why doesn't this return statement return?

The open(...) do notation defines a new anonymous function in the indented block, which is then passed to open as a first parameter. Therefore, the return inside the block exits the anonymous function back into mweret.

In the second function mweret2, the return exits mweret2 function as expected.

TL;DR The do notation is a confusing at first (for me too), but then becomes natural and useful.

9 Likes