生成表示对象 ID 的字符串

Generating a string representing the object id

我有以下对象,我想隐藏 :a_list 和 :b_list 的 attr_accessor,低于

<Namespace::SomeObject:0x00000002674538 @a_list={}, @b_list={}>

我知道我应该重写 inspect 方法,例如:

def inspect
  "#<{self.class}: >"
end

如何获取 ID 0x00000002674538

"%#016x" % (object_id << 1)

"%#016x" % (object_id * 2)