What is the result of "puts sum(1, 2, 3).inspect"?

If the result is "[1, 2, 3]", then you should return sum variable at
the end of sum method like below, but I recommend to use inject method.

def sum (*numbers)

  sum = 0

  numbers.each do |n|

    sum += n if n.is_a? Integer

  end

  sum

end




2014 11 20 , Roelof Wobben<r.wobben / home.nl>  :

> Robert Klemme schreef op 20-11-2014 9:28:
>
>> On Thu, Nov 20, 2014 at 9:23 AM, Jeremy Axelrod
>> <axelrod.jeremy / gmail.com> wrote:
>>
>>> What if you put a number in the array?
>>>
>> In the method you cannot know whether there are numbers in the
>> Enumerable passed to the method.
>>
>> Kind regards
>>
>> robert
>>
>>
>>  Can I have a answer to my question why the test is failing ??
>
> Roelof
>
>

-- 
  3 
010 6701 2676 | ang0123dev / gmail.com