エントリーの編集
エントリーの編集は全ユーザーに共通の機能です。
必ずガイドラインを一読の上ご利用ください。
How to determine if one array contains all elements of another array
記事へのコメント0件
- 注目コメント
- 新着コメント
このエントリーにコメントしてみましょう。
注目コメント算出アルゴリズムの一部にLINEヤフー株式会社の「建設的コメント順位付けモデルAPI」を使用しています
- バナー広告なし
- ミュート機能あり
- ダークモード搭載
関連記事
How to determine if one array contains all elements of another array
Given: a1 = [5, 1, 6, 14, 2, 8] I would like to determine if it contains all elements of: a2 = [2... Given: a1 = [5, 1, 6, 14, 2, 8] I would like to determine if it contains all elements of: a2 = [2, 6, 15] In this case the result is false. Are there any built-in Ruby/Rails methods to identify such array inclusion? One way to implement this is: a2.index{ |x| !a1.include?(x) }.nil? Is there a better, more readable, way?

