Reputation: 1092
for i in 1..5
retry if i > 2
puts "Value of local variable is #{i}"
end
When I ran the code above, I got an error message saying Invalid retry
The version of Ruby I was using is 1.9.3. Would anyone know what went wrong with the code?
Upvotes: 2
Views: 347
Reputation: 12837
From Ruby 1.9 onwards retry needs to be in a rescue clause and will only work when in a rescue clause
Upvotes: 3