[ruby-core:70808] [Ruby trunk - Feature #11473] Immutable String literal in Ruby 3

From: duerst@...
Date: 2015-09-15 03:07:52 UTC
List: ruby-core #70808
Issue #11473 has been updated by Martin D=C3=BCrst.


Robert A. Heiler wrote:

>     _ =3D ''
>     _ << 'Hello '
>     _ << 'World!'
>=20
> feels cleaner to me than this variant:
>=20
>     _ =3D ''.dup
>     _ << 'Hello '
>     _ << 'World!'

One way to write this would be

_ =3D ''
_ +=3D 'Hello '
_ << 'World!'

However, in a more complicated context, it may not be easy to know when the=
 first change to the empty string occurs (assuming that using +=3D in all c=
ases is less efficient).


----------------------------------------
Feature #11473: Immutable String literal in Ruby 3
https://bugs.ruby-lang.org/issues/11473#change-54191

* Author: Koichi Sasada
* Status: Open
* Priority: Normal
* Assignee: Yukihiro Matsumoto
----------------------------------------
Matz said "All String literals are immutable (frozen) on Ruby 3".

This ticket is place holder to discuss about that.




--=20
https://bugs.ruby-lang.org/

In This Thread

Prev Next