In Ruby, retry is mostly used in the context of exception management. When an exception occurs inside a begin block, control is passed to the rescue block, which handles the situation. Following that, the code beneath the rescue block is typically executed.
Simply stop the begin block once the task is completed (for example, payment is made). However, if the task has not been completed or has failed (for example, a payment has failed), we will redirect our call to the retry statement, which will request the task again from the same location.
The first type is a simple retry statement, which will execute the code block again until it succeeds. The second type is a retry-with-exception statement, which will execute the code block again but with an exception thrown if it fails.
The continue statement is used to execute a block of code after an exception is thrown. The retry statement is used to execute a block of code repeatedly until it succeeds.
Share With Friend
Have a friend to whom you would want to share this course?
Download LearnVern App
Code Scan
or
Download the app
598K+
Downloads
4.57
Avg. Ratings
15K+
Reviews
Learn anywhere on the go
Get regular updates about your enrolled or new courses
Share content with your friends
Evaluate your progress through practice tests
No internet connection needed
Enroll for the webinar and join at the time of the webinar from anywhere
Enjoying this course!
All the Courses on Learnvern are Free! So Register/Sign in to
have Access all the Courses and Videos.