LoginSignup
1
0

More than 1 year has passed since last update.

Ruby | pry とか p で表示される アットマークって何なの?

Last updated at Posted at 2018-06-03

答え

インスタンス変数。
メソッドの戻り値とかじゃないので注意。

コード例

class A
  def initialize
    @some_instance_variable = :example
  end
end

p A.new # #<A:0x00007fc3930961c8 @some_instance_variable=:example>

ちなみに

  • pの結果にはinspectメソッドが使われる。

環境

  • ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin17]

参考

チャットメンバー募集

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

Twitter

1
0
0

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
1
0