I have this array
a = [[1,2,3,4,5],[2,3,6],[2,8,9]]
How can I get the intersection of all the arrays in a
? It should be the same as a[0]&a[1]&a[2]
, which is:
[2]
a = [[1 ,2, 3, 4, 5], [2, 3, 6], [2, 8, 9]]
a.inject(:&)
# => [2]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.