8
10

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.

Rubyで配列内に要素があるか検索

Last updated at Posted at 2016-09-28

include?を使って配列内に要素があるかどうかを判定する
対象の配列.include?(配列内に存在するか確かめたい値)

念のため例をしたに出しておきます。

@hoge = 'bird','dog','cat'
// 以下でtrueが返ってきます。
@hoge.include?('cat')

8
10
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
8
10

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?