Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
配列 があり、次のようなメソッドがある場合は、一致する値を抽出したい[1, 2, 5]と思います。[1, 2, 3]
[1, 2, 5]
[1, 2, 3]
[1, 2, 5].match([1, 2, 3]) #=> [1, 2]
配列に方法はありますか、ありがとう
非常に簡単:
[1,2,5] & [1,2,3] #=> [1,2]
その他の便利な配列操作には、次のものがあります。
[1,2,3] | [1,3,4] #=> [1,2,3,4] [1,2,3] - [1,3,4] #=> [2] [1,2,3] + [1,3,4] #=> [1,2,3,1,3,4]