In Ruby, is there an easy way to multiply each element in an n-dimensional array by one number?
Thus: [1,2,3,4,5].multiplied_by 2 == [2,4,6,8,10]
and [[1,2,3],[1,2,3]].multiplied_by 2 == [[2,4,6],[2,4,6]] ?
(Obviously, I made up the multiplied_by function to distinguish it from * , which seems to combine multiple copies of the array, which, unfortunately, is not what I need).
Thanks!
source share