Performing an outer join on two Ruby Arrays
Let's say I have two Arrays in Ruby, containing user IDs.
These are the old users:
== old ==
1
2
3
4
And these are the new:
== new ==
2
3
4
5
6
I want to find out the IDs of new users, so in that case, 5 and 6. I guess what I want is a left outer join of NEW and OLD, but I don't know how to do tha开发者_运维知识库t with simple arrays.
I'm relatively new to Ruby, so there might be a simple and effective solution for this, rather than iterating over everything.
old = [1, 2, 3, 4]
new = [2, 3, 4, 5, 6]
p new - old #=[5, 6]
精彩评论