Your Sum

Note: This problem needs knowledge of topics you haven't covered yet. Reading List

Problem Statement

Given a custom class MyArray,
write a 'sum' method that takes a block parameter.

my_array =[1, 2, 3])
my_array.sum gives 6
my_array.sum(10) gives 16
my_array.sum(0) {|n| n ** 2 } gives 14


Remember yield?
And block_given??

Output Window

Reading list for this problem

You are yet to work on:

Congratulations, guest!

% of the book completed