A Programming Idiom You've Never Heard Of 
A similar pattern that blew my mind when I first saw it was ruby's scoped open().instead of  f = open "test.txt"
  print f.read
  f.close

You can write  open "text.txt" do |f|
    print f.read
  end

The file is automatically closed at the end of the block, and it also handles exceptions and so on. I find it also lines up better semantically with how I think about opening handles to things.I believe Python also added something similar via the 'with' syntax. Not sure about other languages.