Getting More Creative- scope


how can the create method reach variable @files which is in the initialize method?

my code is passing the exercise

class Computer
  @@users = {}
  def initialize(username, password)
    @username = username
    @password = password
    @files = {}
    @@users[username] = password
  def create(filename)
    time =
    @files[filename] = time
    puts "file is created"

  def getfiles
    @files.each {|x| puts x}
["new_file.txt", 2017-11-05 18:59:50 +0000]
["next_file.txt", 2017-11-05 18:59:50 +0000]
["last_file.txt", 2017-11-05 18:59:50 +0000]


Hi, thanks for your response.
I don’t get how that answers my question.

My code is working fine, I just wanted to know how does create method reach variable @files which belongs to initialize method?


Have you tried using an accessor?


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.