Feature #11346
closedNew #intern_str or similarly-named method of Symbol to return a cached, frozen string (like "string".freeze)
Description
While I don't think it would be a good idea to change the behavior of the existing Symbol#to_s method as suggested in issue 11066, I think that it would be extremely useful to have some instance method of Symbol to perform that operation.
If such a method is added, it might be nice if String, and maybe even Object offered the same method so the operation could be performed with indifference to the target and so optimizations could be applied to Classes other than just Symbol (e.g. NilClass, TrueClass, FalseClass, and maybe for smallish values of Fixnum).
Perhaps, the new method name would be #intern_str, and if that is added to Object, the default implementation could be something like to_s.intern_str
which would abide by the contract of always returning the same frozen string object (assuming #to_s does), even though it builds an ordinary string as an intermediate object, so is not optimized.