2015-08-14

Ruby : kill child class

just code ... ha ha ...

  class KillChild
    def self.inherited(child_class)
      Object.send(:remove_const, child_class.to_s.to_sym)
    end
  end
可惜沒有 mixin 的 X"D & part 2

  "".class.object_id
  #=> 70358229142320
  String.object_id
  #=> 70358229142320
  class TempString < String ; end ; Object.send(:remove_const, :String) ; class String < TempString ; end
  "".class.object_id
  #=> 70358229142320
  String.object_id
  #=> 70358232176640
hahaha...換掉了||| & part 3

  # ~/.irbrc

  Object.send(:remove_const , :String)
  Object.send(:remove_const , :Fixnum)
hmm...anyway,單純有趣的部分就是

沒有留言:

張貼留言