May 19 2010

Immutable Ruby?

Got bored and hacked around.  Found this sort of interesting…
class Object
  def self.new( *args, &blk )
    o = allocate
    o.instance_eval{initialize( *args, &blk )}
    o.freeze
    o
  end
end
Forcing objects to be frozen after initialization?  Almost sounds … functional.
  • Share/Bookmark