Looking for a more efficient way of filtering an array of arrays using another array in Ruby. Let me demonstrate. Starting with this:
core = [[1, "apple", "James Bond"],
[5, "orange", "Thor"],
[10, "banana", "Wolverine"],
[15, "orange", "Batman"],
[20, "apple", "Mickey Mouse"],
[25, "orange", "Lee Adama"],
[30, "banana", "Luke Skywalker"]]
filter = ["apple", "banana"]
result = core.magical_function(filter)
# result == [[5, "orange", "Thor"],
# [15, "orange", "Batman"],
# [25, "orange", "Lee Adama"]]
The only thing I can think of is looping through the filter elements, but this slows down my code a lot when this toy example gets more complicated.