I am getting an error I don't understand. It runs how I intended but throws an error at the end. I am still new to ruby but I know it has something to do with my for loops.
This is my code
nums = Array.new(24){Array.new(80){'X'}}
system('cls')
for i in 0..24
for j in 0..79
print nums[i][j]
end
end
And this is the error messages
K:/Ruby 2/RubyInvaders.rb:5:in block (2 levels) in <main>': undefined method `[]' for nil:NilClass (NoMethodError)
from K:/Ruby 2/RubyInvaders.rb:4:in each'
from K:/Ruby 2/RubyInvaders.rb:4:in block in <main>'
from K:/Ruby 2/RubyInvaders.rb:3:in each'
from K:/Ruby 2/RubyInvaders.rb:3:in <main>'
Its ok to offer better ways to do this but I would also like to understand why I am getting this error