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

Explain the use of global variable $ in Ruby?

1 Answers  


How to write multiline string in Ruby?

1 Answers  


Explain about garbage collection feature of ruby?

1 Answers  


What is the scope of a local variable in ruby?

1 Answers  


Please explain the role of thread pooling in relation to the thread lifecycle in ruby?

1 Answers  


What is request.xhr?

1 Answers  


what is a class library in Ruby?

1 Answers  


What is the difference between calling super and calling super()?

1 Answers  


How would you freeze an object in ruby?

1 Answers  


How to access Ruby array elements? How many methods are used to access Ruby elements?

1 Answers  


What is the difference between nil and false in ruby?

1 Answers  


What are Ruby iterators?

1 Answers  


Categories