The only case I can think of for redois for operations such as writing to a socket or reading from a database, but if they are not executed once, subsequent attempts will most likely also fail, so it still seems a little pointless me, and as for retry, I canโt think of any case when it would be useful.
redo
retry
It may seem pointless to me because I donโt know or am not using Ruby, but I am trying to create an amazing language one day, so I would like to at least find out about the design of some of the most popular languages.
, - , redo retry, , , , . redo, retry , . , , - - (, ), , , , retry begin...rescue. , , .
begin...rescue
, , Net:SFTP. , . , . , , , , . :
Net:SFTP
tried_mkdir = false begin # Attempt to access remote directory ... rescue Net::SFTP::StatusException raise if tried_mkdir tried_mkdir = true # Attempt to make the remote directory ... retry end
redo :
nums = Array.new(5){[rand(1..9), rand(1..9)]} nums.each do |num1, num2| print "What is #{num1} + #{num2}: " redo unless gets.to_i == num1 + num2 end