Skip to content Skip to sidebar Skip to footer

Advanced Tutorials

Advanced Tutorials

How to Use The Begin and Rescue Keywords in Ruby

Begin and Rescue keywords in Ruby allow to execution of some code if an error occurs during the program's implementation. Rescuing Standard Errors The rescued code will execute only if a StandardError or its descendants occur. For example: begin some_undefined_method some_undefined_variable rescue puts "An error occurred." end It's also possible to handle different speeches of errors: begin …

Read more