#inspect on BasicObject oddity

问题描述 投票:0回答:0

继承BasicObject时会出现以下情况:

class Test < BasicObject
  def inspect
    "foobar"
  end
end

test = Test.new

test.inspect
# => "foobar"

test
(Object doesn't support #inspect)
=>

是否有可能以某种方式实施检查以使其在 IRB 中正常运行?

ruby inspect
© www.soinside.com 2019 - 2024. All rights reserved.