Answer Posted / Ajeet Kumar Rawat
The 'ensure' keyword in Ruby is used in combination with 'begin' and 'rescue'. It ensures that a block of code gets executed no matter whether an exception occurs during the execution of the 'begin-rescue' block or not. The 'ensure' block is always executed after the 'begin-rescue' blocks, providing an opportunity to clean up resources such as closing files or network connections.
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers