Following development of Ruby 2.1 I have read about a feature that will probably be added so a developer is allowed to specify that a literal String should start out "frozen".
The syntax looks like this (note the trailing f
):
str = "imfrozen"f # str receives a frozen string
In other Ruby documentation/wiki i've read that this feature provides the following benefit:
This allows the VM to use the same String object each time, and potentially for the same frozen string across many files. It also obviously provides all the immutability guarantees of a frozen string.
My questions are:
- What is the benefit of this?
- What is a real world example of when a feature like this would provide value?
- How is this different from a
symbol
?
Thank you