Here's what I'm trying to do:
val1 = [26, 27, 24, 25, 29, 28]
val2 = [17, 20, 22, 21]
val3 = [36, 33, 31, 29]
val4 = [20, 18, 17, 22, 21, 23]
vals = {val1, val2, val3, val4}
sum = 0
count = 0
vals.each do |val|
for i in 0..val.size-1 do
#sum += val[i]
p val[i]
++count
end
end
puts sum
puts count
Initially I wanted to just get sum and count, but that wasn't working so I tried printing. I can see that the val[i]
isn't working as I intended though. I tried doing this:
vals.each do |val|
aux = val.to_a
for i in 0..aux.size-1 do
p aux[i]
++count
end
end
But it had the same results. I'm still trying to learn the basics, so I really have no idea what to do now.