Joel Pearson wrote in post #1121289:
> Just use error handling properly.
>
> begin
> #standard code
> rescue
I am looking for the below operations,but only when error will be
occured :
a = (1..10)
i=0
until a.size>10
next i+=1 if i<5 # this should be done on Error
p a[i]
i+=1
end
If still I
Maybe a real example would help, rather than infinite-loop pseudo-code.
val = -3
until val > 2
begin
val +=1
1/val
rescue
puts 'Error on ' + val.to_s
else
puts 'No Error on ' + val.to_s
end
puts 'Finished with ' + val.to_s
end
--
Posted via http://www.ruby-forum.com/.
Just use error handling properly.
begin
#standard code
rescue
#only runs if an error occurred
else
#only runs if an error did not occur
ensure
#always runs at the end regardless of error level
end
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed
3 matches
Mail list logo