Problem Statement
Given a custom class MyArray,
write a 'sum' method that takes a block parameter.
my_array = MyArray.new([1, 2, 3])
my_array.sum
gives 6
my_array.sum(10)
gives 16
my_array.sum(0) {|n| n ** 2 }
gives 14
Note: This problem needs knowledge of topics you haven't covered yet. Reading List
Given a custom class MyArray,
write a 'sum' method that takes a block parameter.
my_array = MyArray.new([1, 2, 3])
my_array.sum
gives 6
my_array.sum(10)
gives 16
my_array.sum(0) {|n| n ** 2 }
gives 14
You are yet to work on: