Project

General

Profile

Actions

Bug #6037

closed

#freeze bug

Added by ddebernardy (Denis de Bernardy) about 12 years ago. Updated over 11 years ago.

Status:
Rejected
Assignee:
-
Target version:
-
ruby -v:
1.9.3
Backport:
[ruby-core:42687]

Description

freeze should deep freeze, to avoid inconsistent behavior:

array = ['a', 'b'].freeze
array[0] = 'b'
array[0].gsub!(/.+/s, 'b')
array

RUBY_VERSION
=> "1.9.3"
array = ['a', 'b'].freeze
=> ["a", "b"]
array[0] = 'b'
RuntimeError: can't modify frozen Array
from (irb):269:in []=' from (irb):269 from /opt/local/bin/irb:12:in '
array[0].gsub!(/.+/s, 'b')
=> "b"
array
=> ["b", "b"]

Actions

Also available in: Atom PDF

Like0
Like0Like0