sam.saffron / gmail.com wrote:
> "If the string is frozen, then return the string itself."
> 
> Yeah I do not agree with this documentation, I think it should be changed. 
> 
> Trouble is that there is no simple way to de-duplicate
> unconditionally without either inefficiency or side effects:

Yeah, I originally proposed a new method back in the day but
compromised with String#-@ <https://bugs.ruby-lang.org/issues/13077>

> Say `x` is an arbitrary string (either frozen or unfrozen) :
> 
> ```
> x = -x # may return a non fstring
> 
> x = -+x # will return fstring, but makes an unneeded copy
> 
> x = -x.dup # fstring again, uneeded copy 

Maybe these can be optimized in the VM (still ugly, and
redefinition checks aren't free, either).

> x = x.frozen? ? -+x : -x # too verbose
> ```
> 
> Instead why not change it so `-` deduped unconditionally? 

At this point, it may break existing code :<

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>