H
Hakusa
I'm doing the pascal quiz on rubyquiz.com, but I'm finding that I'm
having trouble assigning a value to my array.
I've assigned it like this:
pyramid_lvl[level] =\
( (pyramid[level-1][i-1]).to_i \
+ (pyramid[level-1] ).to_i )
and like this:
num1 = pyramid[level-1][i-1].to_i
num2 = pyramid[level-1].to_i
ans = num1+num2
pyramid_lvl[level] = [ans]
Both give me this error message:
undefined method `[]=' for 1:Fixnum (NoMethodError)
Am I getting this problem because I don't understand how arrays work
and it's simply a matter of operations, or am I having some serious
logical problem preventing correctness.
having trouble assigning a value to my array.
I've assigned it like this:
pyramid_lvl[level] =\
( (pyramid[level-1][i-1]).to_i \
+ (pyramid[level-1] ).to_i )
and like this:
num1 = pyramid[level-1][i-1].to_i
num2 = pyramid[level-1].to_i
ans = num1+num2
pyramid_lvl[level] = [ans]
Both give me this error message:
undefined method `[]=' for 1:Fixnum (NoMethodError)
Am I getting this problem because I don't understand how arrays work
and it's simply a matter of operations, or am I having some serious
logical problem preventing correctness.