Project

General

Profile

Actions

Bug #11828

closed

Object#freeze grid-locks Ruby

Added by danielpclark (Daniel P. Clark) over 8 years ago. Updated over 8 years ago.

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

Description

It seems safe to freeze most any class type in Ruby. But if you call Object.freeze nothing from then on can be created in either class of method form.

Is this okay behavior to have in Ruby?

Object.freeze

class A
end
# => RuntimeError: can't modify frozen #<Class:Object>

def x
end
# => RuntimeError: can't modify frozen class

I noticed that Procs can still be defined.

prc = proc {|a| a+1}

prc.call(4)
# => 5 

But all singleton instances are frozen.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0