I got 2 arrays:
a = [1,2,3,4,5]
b = [4,5,6,7,8]
I want to delete every b element in a, in order for a to have [1,2,3]
Of course, my real arrays are different.
I want a beautiful answer with a simple method, since I can resolve this issue by using this loop, but I find it ugly.
b.each do |e|
a.delete(e) if a.include?(e)
end
return a
It seems that reject may be the way to go, but couldn't find the good way. Thanks you
a-bto get what you wanted.