The Poignant Guide provides an example of this redo keyword:
class LotteryTicket def self.new_random new(rand(25) + 1, rand(25) + 1, rand(25) + 1) rescue ArgumentError redo end end
He should keep calling new until all three random numbers are unique. But after I typed this code and ran it several times, I got this error: LocalJumpError: unexpected redo . I was looking for the redo keyword elsewhere, and it looks like it should only work for loops and iterators. So why did you try to use it in this example? How should this method be rewritten to work correctly?
source share