begin : rescue « Statement « Ruby
- Ruby
- Statement
- rescue
begin
names=IO.readlines("C:\\customer_details1.txt")
count=names.length
for i in 0...count
puts "The contents of the file are #{names[i]}"
end
rescue
$stderr.puts "error"
puts "The error occurred is #{$!}"
end
Related examples in the same category