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 |
Tell me can you call a private method outside a ruby class using its object?
What's the difference in scope for these two variables: @name and @@name?
What is the difference between ruby 1.9 and ruby 2.0?
What are the looping structures available in ruby?
What things we can define in the model?
what is the difference extend and include?
Explain the use of retry statement in ruby?
How do you handle exceptions in ruby code?
What are class libraries in Ruby?
What are the different uses of ruby modules?
Explain me what is the difference between symbol and string?
How is an iterator handled in ruby?