Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


Explain the use of ensure statement in Ruby?



Explain the use of ensure statement in Ruby?..

Answer / 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

More Ruby Interview Questions

Can method names be capitalized?

1 Answers  


What is the difference between #== and #eql??

1 Answers  


What is the difference between “#==” and “#equal?”

1 Answers  


What are freezing string in Ruby?

1 Answers  


In how many ways you can compare Ruby string?

1 Answers  


How do you handle exceptions in ruby code?

1 Answers  


Explain redo statement in Ruby?

1 Answers  


Tell us the types of variables available in ruby class?

1 Answers  


Ruby support single inheritance/multiple inheritance or both?

1 Answers  


What are some advantages of using ruby?

1 Answers  


How will you rename and delete a file in Ruby?

1 Answers  


Tell me what does ruby name refers to?

1 Answers  


Categories