>>>>> "TAKAHASHI" == TAKAHASHI Masayoshi <maki / inac.co.jp> 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)