Trouble with array of dictionaries, ruby
        Posted  
        
            by user299450
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by user299450
        
        
        
        Published on 2010-03-22T22:36:43Z
        Indexed on 
            2010/03/22
            22:41 UTC
        
        
        Read the original article
        Hit count: 259
        
ruby
I am getting the following error.
game.rb:46:in `play': undefined method `[]' for nil:NilClass (NoMethodError)
from game.rb:45:in each'
 from game.rb:45:inplay'
 from game.rb:56
with this code,
def play() currentTile = nil @tiles.each do |tile| if(tile['Name'] == 'Starting Square') currentTile = tile end
                    puts("#{currentTile['Desciption']}")
            end
end
This is part of a text adventure game, I am playing with @tiles is an array of tiles that was read from a file. Each tile is a dictionary.
Thanks for any help, I cant figure this out
© Stack Overflow or respective owner