6
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Ruby | オブジェクトを表示する時の 16進数って何なの? ( Object#inspect / Object#to_s )

Last updated at Posted at 2018-06-06

エンコードされた object_id っぽい。

値を2倍 ( 左に1bitシフト ) して16進数にしたもののようだ。

o = Object.new

p o # #<Object:0x00007f9a3081f098>

p o.object_id # 70150107756620

p o.object_id << 1 # 140300215513240

p (o.object_id << 1).to_s(16) # "7f9a3081f098"

参考

The default to_s prints the object's class and an encoding of the object id.

チャットメンバー募集

何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。

Twitter

6
4
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?