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.
这是场景
a = [1,2,3] b = [2,5,6]
我想找出 的哪些元素b不存在于a. 我可以include?用来检查哪些是。但我在这里寻找完全相反的东西。
b
a
include?
> a - b => [1, 3] > b - a => [5, 6]
(我不知道你想走哪条路。)
a = [1,2,3] b = [2,5,6] b - a #=> [5, 6]