From: Stefan Kaes Date: 2005-11-18T23:47:13+09:00 Subject: Re: Question about begin, rescue, end. Robert Klemme wrote: >A general remark: You can greatly improve reliability of your code by >replacing > >the_file = File.new("SitePingLog.txt", "a") >the_file.puts('Got it in '+ the_wait_time.to_s + ' seconds @ ' + >Time.now.to_s) >the_file.close > >with > >File.open("SitePingLog.txt", "a") do |the_file| > the_file.puts('Got it in '+ the_wait_time.to_s + ' seconds @ ' + > Time.now.to_s) >end > > I'd prefer File.open("SitePingLog.txt", "a") do |file| file.puts("Got it in #{the_wait_time} seconds @ #{Time.now}") end ;-)