Hi aaall,
I have a code like this (from Why’s (poignant) guide to Ruby, in
http://poignantguide.net/ruby/chapter-5.html#section5):
class LotteryTicket
NUMERIC_RANGE = 1…25
attr_reader :picks
def initialize( *picks )
if picks.length != 3
raise ArgumentError, “three numbers must be picked”
elsif picks.uniq.length != 3
raise ArgumentError, “the three picks must be different numbers”
elsif picks.detect { |p| not NUMERIC_RANGE === p }
raise ArgumentError, “the three picks must be numbers between 1
and 25.”
end
@picks = picks
end
def LotteryTicket.new_random
new( rand( 25 ) + 1, rand( 25 ) + 1, rand( 25 ) + 1 )
rescue ArgumentError
redo
end
end
ticket = LotteryTicket.new_random()
When the 3 random numbers created in this last line are not equal,
everything goes right. However, when two or three are identical, the
second argument error is raised and, theoretically, the method
“new_random” should be run automatically again. However, an exception
cames out:
in `new_random’: unexpected redo (LocalJumpError)
This exception should not be launched… (I thought). Suggestions?
On Jul 08, 2006, at 8:37 pm, Damaris F. wrote:
When the 3 random numbers created in this last line are not equal,
everything goes right. However, when two or three are identical, the
second argument error is raised and, theoretically, the method
“new_random” should be run automatically again. However, an exception
cames out:
in `new_random’: unexpected redo (LocalJumpError)
This exception should not be launched… (I thought). Suggestions?
He must have meant to type “retry” instead of “redo”. redo is for
loops only AFAIK
Ashley
Yes! It works fine with retry! Thanks! 
Ashley M. wrote:
On Jul 08, 2006, at 8:37 pm, Damaris F. wrote:
When the 3 random numbers created in this last line are not equal,
everything goes right. However, when two or three are identical, the
second argument error is raised and, theoretically, the method
“new_random” should be run automatically again. However, an exception
cames out:
in `new_random’: unexpected redo (LocalJumpError)
This exception should not be launched… (I thought). Suggestions?
He must have meant to type “retry” instead of “redo”. redo is for
loops only AFAIK
Ashley
On 8-jul-2006, at 21:37, Damaris F. wrote:
This exception should not be launched… (I thought). Suggestions?
Maybe he mistyped and meant “retry” instead?