Project

General

Profile

Actions

Bug #5235

closed

Ruby fails to freeze Strings and Numerics.

Added by katmagic (Kat Magic) over 13 years ago. Updated over 13 years ago.

Status:
Rejected
Assignee:
-
Target version:
ruby -v:
ruby 1.9.2p0 (2010-08-18 revision 29036) [i686-linux]
Backport:
[ruby-core:39127]

Description

x = 0
x.freeze()
x += 1
x # => 1

s = ""
s.freeze()
s += "a"
s # => "a"

Updated by aprescott (Adam Prescott) over 13 years ago

This is not a bug. x += 1 is sugar for x = x + 1, and x + 1 does not
modify the receiver. Similar for s += "a".

s = ""
s.freeze
s.replace("nothing") #=> RuntimeError: can't modify frozen string

Updated by matz (Yukihiro Matsumoto) over 13 years ago

  • Status changed from Open to Rejected

#freeze prohibits modification to an object, not a variable.

Actions

Also available in: Atom PDF

Like0
Like0Like0