以下代码:
def array_sum(*n)
sum = 0
0.upto(a.length-1) do |i|
sum += n[i]
end
return sum
end
a = (1..5).to_a
puts array_sum(a)
给了我一个模棱两可的错误:
“/Users/Josh/Documents/Aptana Studio 3 Workspace/Test/Euler7.cgi:10:in
array_sum': undefined local variable or method
a' for main:Object (NameError) from /Users/Josh/Documents/Aptana Studio 3 Workspace/Test/Euler7.cgi: 17"
谁能帮我吗?