retry does not work

T

T. Onoma

matz:

you rejected my rcr on garden saying that retry already does it. but it does not. maybe there's a trick to it? but i could not read your example b/c it was cut off by the < --you have to use &lt; [Aside: why hasn't this been fixed at garden? argghhh..]

so please show me how resume would work with retry here. here is the example again:

def resume_example(x)
begin
print x
x = x + 4
if x < 10
raise
end
print x
rescue
x = 10
resume # if retry -> 51014
end
puts
end
resume_example(5) # -> 510

thanks matz,
-t0
 
T

ts

T> you rejected my rcr on garden saying that retry already does it. but it
T> does not. maybe there's a trick to it? but i could not read your example
T> b/c it was cut off by the < --you have to use &lt; [Aside: why hasn't
T> this been fixed at garden? argghhh..]

Well the example was probably

def resume_example(x)
print x
x += 4
begin
raise if x < 10
print x
rescue
x = 10
retry
end
puts
end



Guy Decoux
 
Y

Yukihiro Matsumoto

Hi,

In message "retry does not work"

|you rejected my rcr on garden saying that retry already does it. but it does not. maybe there's a trick to it? but i could not read your example b/c it was cut off by the < --you have to use &lt; [Aside: why hasn't this been fixed at garden? argghhh..]
|
|so please show me how resume would work with retry here. here is the example again:

Check the code carefully (note where "begin" is). It's not just
replacing resume with retry. "retry" jumps back to "begin".

|def resume_example(x)
| begin
| print x
| x = x + 4
| if x < 10
| raise
| end
| print x
| rescue
| x = 10
| resume # if retry -> 51014
| end
| puts
|end
|resume_example(5) # -> 510

def resume_example(x)
print x
x = x + 4
begin
if x < 10
raise
end
print x
rescue
x = 10
retry
end
puts
end
resume_example(5) # -> 510

matz.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,165
Latest member
JavierBrak
Top