[#91458] [Ruby trunk Feature#4475] default variable name for parameter — matz@...
Issue #4475 has been updated by matz (Yukihiro Matsumoto).
3 messages
2019/02/07
[ruby-core:91610] [Ruby trunk Bug#15616] Chained destructive methods fail when using +@to unfreeze a frozen string
From:
pdahorek@...
Date:
2019-02-22 15:51:36 UTC
List:
ruby-core #91610
Issue #15616 has been updated by ahorek (Pavel Rosick.
```
+foo.gsub!("bar", "car")
```
stands for
```
+(foo.gsub!("bar", "car"))
```
and because foo is frozen, you'll get an error, see #15606
try this
```
foo = "bar".freeze
foo = (+foo).gsub!("bar", "car")
```
or
```
foo = "bar".freeze
foo = foo.gsub("bar", "car")
```
----------------------------------------
Bug #15616: Chained destructive methods fail when using +@ to unfreeze a frozen string
https://bugs.ruby-lang.org/issues/15616#change-76877
* Author: cianooooo (Cian O)
* Status: Open
* Priority: Normal
* Assignee:
* Target version:
* ruby -v: 2.6.1
* Backport: 2.4: UNKNOWN, 2.5: UNKNOWN, 2.6: UNKNOWN
----------------------------------------
Using the +@ syntax to unfreeze a string does not work when chaining destructive methods
Consider the following;
``` ruby
foo = "bar".freeze
+foo.gsub!("bar", "car")
```
This raises;
``` ruby
FrozenError: can't modify frozen String
```
However, I would have expected this to work since +@ should return a duplicated mutable string.
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>