I am trying to filter out empty arrays from an array. In other words, I want to transform something that looks like this: ["a", "b", [], [], [1, 2, 3]] to look like ["a", "b", [1, 2, 3]]. My code looks like this:
def removeEmptyArrays(arr)
arr.select{|x| !x.empty?}
endHowever, it seems that I've run into a problem, with an error message of undefined method. Fix my code so that all tests pass.
# What I want:
removeEmptyArrays([1, 2, [], 4]) ➞ [1, 2, 4]
# What I am getting:
block in removeEmptyArrays: undefined method empty? for 1:Fixnum (NoMethodError)N/A