I have three arrays I want to intersect, but I want to ignore the ones that are empty.
This code seems too verbose. Is there a more efficient approach?
if a.empty? && b.empty?
abc = c
elsif a.empty? && c.empty?
abc = b
elsif b.empty? && c.empty?
abc = a
elsif a.empty?
abc = b & c
elsif b.empty?
abc = a & c
elsif c.empty?
abc = a & b
else
abc = a & b & c
end
a,bandcare arrays that may or may not me empty.