LoginSignup
0
1

More than 1 year has passed since last update.

#Ruby で配列の添字・順序を文字列から探す ( find_index )

Last updated at Posted at 2020-01-23
["A","B","C","C","D"].find_index("A")
# => 0

["A","B","C","C","D"].find_index("B")
# => 1

# 複数見つかる場合も最初のものが返る
["A","B","C","C","D"].find_index("C")
# => 2

["A","B","C","C","D"].find_index("D")
# => 4

["A","B","C","C","D"].find_index("E")
# => nil

Original by Github issue

チャットメンバー募集

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

Twitter

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