From: jweirich@... Date: 2001-08-22T11:05:45+09:00 Subject: [ruby-talk:20080] Re: The Ruby Way [was: Ruby Article] >>>>> "TAKAHASHI" == TAKAHASHI Masayoshi writes: TAKAHASHI> It's not only the Ruby Way, but raises an invalid error. TAKAHASHI> If phonespec.txt cannot be open, myfile is `nil' TAKAHASHI> and cannot be closed. TAKAHASHI> myfile = File.open('phonespec.txt', 'a') TAKAHASHI> begin TAKAHASHI> # ... TAKAHASHI> ensure TAKAHASHI> myfile.close TAKAHASHI> end I have been known to write ... def function myfile = open ("xyz") # ... ensure myfile.close if myfile end -- -- Jim Weirich jweirich@one.net http://w3.one.net/~jweirich --------------------------------------------------------------------- "Beware of bugs in the above code; I have only proved it correct, not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)