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,4,5],[2,3,6],[2,8,9]]
我怎样才能得到所有数组的交集a?它应该与 相同a[0]&a[1]&a[2],即:
a
a[0]&a[1]&a[2]
[2]
a = [[1 ,2, 3, 4, 5], [2, 3, 6], [2, 8, 9]] a.inject(:&) # => [2]