Why I Like Ruby
This example shows the thing I like about the Ruby language the most. It is simple but opens up subtle possibilities and works in a way that you don't have to think about. It works exactly as you would expect it to work. It could have worked the other way and Ruby would have suffered for it.
Running this program yields the following output:
$ ruby example.rb calling m before yield in block method f returned: stuff
When calling m and passing a block with a return statement, the return is done from the calling method f. Neither the 'after yield' nor the 'done calling m' statement is executed. This is exactly as it should work, but I can imagine other implementations where one or both of these statements were called. It wouldn't have been as beautiful, however.
As my wife is fond of saying, "It's the little things ..."! Thanks, Matz.