卜部昌平のあまりreblogしないtumblr RSS

Archive

Apr
9th
Fri
permalink

Class.allocateでBasicObjectのクローン

ふつうはできない。

irb(main):001:0> BasicObject.clone
TypeError: can't copy the root class

ところが…

c = Class.allocate
Module.instance_method(:initialize_copy).bind(c).call BasicObject
p c.ancestors        # => [#<Class:0x00000001327098>]

新世界の神が誕生している様子が見て取れる。

まあ、なんというか、俺的には結構頑張ってるんだけどなかなかSEGVしないので困った。これ本当に平気なの?

  1. iwadon reblogged this from shyouhei
  2. atm09td reblogged this from shyouhei
  3. reretlet reblogged this from shyouhei
  4. shyouhei posted this