<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed>
  <author_name>K_Koh</author_name>
  <author_url>https://blog.hatena.ne.jp/K_Koh/</author_url>
  <blog_title>Just do IT</blog_title>
  <blog_url>https://k-koh.hatenablog.com/</blog_url>
  <categories>
    <anon>Ruby</anon>
  </categories>
  <description>やりたいこと ある配列に入った要素をひとつずつ確認して、引数に渡した要素と比較し、合致した場合のインデックスを取得したい。 方法 indexやfind_indexが使える。 指定された val と == で等しい最初の要素の位置を返します。等しい要素がひとつもなかった場合は nil を返します。 Array#find_index (Ruby 2.7.0 リファレンスマニュアル) 今回は find_index を使ってみる。 ary = %w(hoge bar baz hage) #hageが配列の何番目にあるか知りたい puts ary.find_index(&quot;hage&quot;) 結果 $ ruby…</description>
  <height>190</height>
  <html>&lt;iframe src=&quot;https://hatenablog-parts.com/embed?url=https%3A%2F%2Fk-koh.hatenablog.com%2Fentry%2F2020%2F09%2F06%2F203243&quot; title=&quot;Ruby で配列から条件に一致するインデックスを取得したい - Just do IT&quot; class=&quot;embed-card embed-blogcard&quot; scrolling=&quot;no&quot; frameborder=&quot;0&quot; style=&quot;display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;&quot;&gt;&lt;/iframe&gt;</html>
  <image_url></image_url>
  <provider_name>Hatena Blog</provider_name>
  <provider_url>https://hatena.blog</provider_url>
  <published>2020-09-06 20:32:43</published>
  <title>Ruby で配列から条件に一致するインデックスを取得したい</title>
  <type>rich</type>
  <url>https://k-koh.hatenablog.com/entry/2020/09/06/203243</url>
  <version>1.0</version>
  <width>100%</width>
</oembed>
