Actions
Bug #5235
closedRuby fails to freeze Strings and Numerics.
Description
x = 0
x.freeze()
x += 1
x # => 1
s = ""
s.freeze()
s += "a"
s # => "a"
Actions
Like0
Like0Like0
Added by katmagic (Kat Magic) over 13 years ago. Updated over 13 years ago.
Description
x = 0
x.freeze()
x += 1
x # => 1
s = ""
s.freeze()
s += "a"
s # => "a"
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
#freeze prohibits modification to an object, not a variable.