Is there a built-in which will easily allow you to access the objects within an array and its sub arrays so that one can achieve something along the lines of:
array = [5, 10, [15, 20], 25, [30, 35, 40]
array#method { #block that adds 5} => [10, 15, [20, 25], 30, [35, 40, 45]
I'm unconcerned if it is destructive or not.
You could use a recursive lambda:
add_five = lambda { |e| e.is_a?(Enumerable) ? e.map(&add_five) : e + 5 }
new_array = array.map(&add_five)
Adjust the e.is_a?(Enumerable)
test to match your situation, e.is_a?(Array)
would be tighter but possibly unnecessarily so.