If I want to compare two arrays and create an interpolated output string if an array variable from array y exists in x how can I get an output for each
y
x
You can use the set intersection method & for that:
x = [1, 2, 4] y = [5, 2, 4] x & y # => [2, 4]