Skip to content

Instantly share code, notes, and snippets.

@gpherguson
Created November 15, 2010 03:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gpherguson/700004 to your computer and use it in GitHub Desktop.
Save gpherguson/700004 to your computer and use it in GitHub Desktop.
class Dungeon
@@levels = []
def add_level(n, h, w)
@@levels[n] = Level.new(h, w)
end
end
class Level
def initialize(height, width)
@height, @width = height, width
end
end
#/home/lewis/code/ruby/map.rb:4:in `add_level': undefined method `[]=' for nil:NilClass (NoMethodError)
@gpherguson
Copy link
Author

changed @levels to a class variable @@levels

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment