yeyicheng

Untitled

Apr 21st, 2012
28
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.25 KB | None | 0 0
  1. fileName = "idk"
  2. attempt = 1
  3. begin
  4.    file = open(fileName)
  5.    if file
  6.       puts "File opened successfully at #{attempt} attempt"
  7.    end
  8. rescue
  9.     puts "#{attempt} attempt failed"
  10.     attempt += 1
  11.     fileName = "1.rb"
  12.     retry
  13. ensure
  14.     puts "test end"
  15. end
Advertisement
Add Comment
Please, Sign In to add comment