Apply a callback to an array
Apply a callback function to each element of an Array
Apply a callback to an array
You are encouraged to solve this task according to the task description, using any language you may know.
You are encouraged to solve this task according to the task description, using any language you may know.
Ruby
#create the array ary = [1,2,3,4,5] #create the function (print the square) def print_square(i) puts i**2 end #ruby ary.each do |i| print_square(i) end # prints 1,4,9,16,25