摘要: irb(main):001:0> a = Object.new
=> #
irb(main):002:0> a.object_id #获取对象ID
=> 70350817702340
irb(main):003:0> a.class #获取对象类型
=> Object
irb(main):004:0> Integer.superclass #获取父类
=> Numeric
irb(main):006:0> Numeric.superclass #...
=> Object
irb(main):007:0> Object.superclass #Object父类为 nil
=> nil
irb(main):011:0> Integer.ancestors #获取类的父类及 include 的类
=> [Integer, Precision, Numeric, Comparable, Object, Kernel]
irb(main):013:0> Integer.class #类的类型是 Class
=> Cla阅读全文