Retry does not work

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 < [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

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..]

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

Hi,

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 < [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.
···

In message “retry does not work” on 03/11/20, “T. Onoma” transami@runbox.com writes: