Ruby - Methods
How can you modify this method to explicitly return the sum?
def sum_numbers(nums)
total = 0
nums.each do |n|
total += n
end
total
enddef sum_numbers(nums)
total = 0
nums.each do |n|
total += n
end
total
endreturn total after the loop explicitly returns the sum.15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions