Ruby - Arrays
What will be the output of this Ruby code?
arr = [1, [2, 3], [4, 5]] puts arr.flatten.include?(3)
arr = [1, [2, 3], [4, 5]] puts arr.flatten.include?(3)
arr.flatten converts [1, [2, 3], [4, 5]] into [1, 2, 3, 4, 5].include?(3) returns true because 3 is in the flattened array.15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions