Ruby - Methods
Given this Ruby method, what will it return?
def complex
arr = [1, 2, 3]
arr.map { |n| n * 2 }
arr
end
result = complexdef complex
arr = [1, 2, 3]
arr.map { |n| n * 2 }
arr
end
result = complexarr.map { |n| n * 2 } creates a new array but does not modify arr. The last expression is arr.arr, which is still [1, 2, 3].15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions