class File
def File.Open(*args)
result=f=File.new(*args)
if block_given?
begin
result=yield f
ensure
f.close
end
return result
end
end
注: ensure用于必定要执行的语句
class File
def File.Open(*args)
result=f=File.new(*args)
if block_given?
begin
result=yield f
ensure
f.close
end
return result
end
end
注: ensure用于必定要执行的语句