4
3

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 5 years have passed since last update.

is_a?(Arry)メソッド

Posted at

###is_a?(Arry)メソッド
レシーバのオブジェクトが引数クラスのインスタンスであればtrue、そうでなければfalseを返します。
この場合だとarryならtrueを返す
https://ref.xaio.jp/ruby/classes/object/kind_of

#####コンソールで試した

[1] pry(main)> arr = [1,2,3]
=> [1, 2, 3]

[2] pry(main)> arr.is_a?(Array)
=> true

[3] pry(main)> arr.is_a?(Hash)
=> false

[4] pry(main)> b = {unko: 3}
=> {:unko=>3}

[5] pry(main)> b.is_a?(Hash)
=> true

[6] pry(main)> b.is_a?(Array)
=> false

4
3
1

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
4
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?