Project

General

Profile

Actions

Bug #15616

closed

Chained destructive methods fail when using +@ to unfreeze a frozen string

Added by cianooooo (Cian O) about 5 years ago. Updated about 5 years ago.

Status:
Rejected
Assignee:
-
Target version:
-
[ruby-core:91609]

Description

Using the +@ syntax to unfreeze a string does not work when chaining destructive methods

Consider the following;

foo = "bar".freeze
+foo.gsub!("bar", "car")

This raises;

FrozenError: can't modify frozen String

However, I would have expected this to work since +@ should return a duplicated mutable string.

Actions

Also available in: Atom PDF

Like0
Like0Like0