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"
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
Like0
Like0Like0