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...


Tell me how would you freeze an object in ruby? Can you provide a simple example?



Tell me how would you freeze an object in ruby? Can you provide a simple example?..

Answer / Swamjeet Singh

In Ruby, you can freeze an object to prevent it from being modified by using the `freeze` method. Once frozen, the object cannot be altered and will raise a RuntimeError if any attempt is made to modify it.n- For example: `obj = {}.freeze; obj[:key] = 'value' # raises RuntimeError`

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Ruby Interview Questions

Tell me can you call a private method outside a ruby class using its object?

1 Answers  


What's the difference in scope for these two variables: @name and @@name?

1 Answers  


What is the difference between ruby 1.9 and ruby 2.0?

1 Answers  


What are the looping structures available in ruby?

1 Answers  


What things we can define in the model?

1 Answers  


what is the difference extend and include?

1 Answers  


Explain the use of retry statement in ruby?

1 Answers  


How do you handle exceptions in ruby code?

1 Answers  


What are class libraries in Ruby?

1 Answers  


What are the different uses of ruby modules?

1 Answers  


Explain me what is the difference between symbol and string?

1 Answers  


How is an iterator handled in ruby?

1 Answers  


Categories