LoginSignup
1
1

More than 5 years have passed since last update.

["hoge"][0]のクラス

Posted at
[1] pry(main)> ["hello"][0].class
=> String
[2] pry(main)> ["hello"][1].class
=> NilClass
[3] pry(main)> ["hello"].class
=> Array
[4] pry(main)> ["hello", "world"][0].class
=> String

今日初めて知った。
自分が見た例文では文字列表示の条件分岐で使ってた。
他に何に使えるかわからないけど、知識としてストック。

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