From: TAKAHASHI Masayoshi Date: 2001-08-22T10:29:18+09:00 Subject: [ruby-talk:20076] Re: The Ruby Way [was: Ruby Article] Hi, jweirich@one.net wrote: > ---------------------------------------------------------------------- > IV) Take advantage of blocks to do automatic closing > > ORIGINAL > begin > myfile = File.open('phonespec.txt', 'a') > # ... > ensure > myfile.close > end file = File.open It's not only the Ruby Way, but raises an invalid error. If phonespec.txt cannot be open, myfile is `nil' and cannot be closed. myfile = File.open('phonespec.txt', 'a') begin # ... ensure myfile.close end TAKAHASHI Masayoshi