7/8 Instantiation Nation

ruby

#1

I'm having some issues with exercise 7. When I save and send the code, this error appears:

uninitialized class variable @@users in Context::Computer

What's wrong with my code?

class Computer
    def Computer.get_users
        return @@users
    end
def create(filename)
    time = Time.now
    @files[filename] = time
    puts "File #{@filename} was created by #{@username} at #{time}."
end
    @@user = {}
def initialize(username, password)
    @username = username
    @password = password
    @files = {}
    @@users[username] = password
  end
end

my_computer = Computer.new("Lo", 3555

#2

You're missing an 's'.

@@user should be @@users


#3
class Machine
  @@users = {}
  
  def initialize(username, password)
    @username = username
    @password = password
    @@users[username] = password
    @files = {}
  end
  
  def create(filename)
    time = Time.now
    @files[filename] = time
    puts "#{filename} was created by #{@username} at #{time}."
  end
  
  def Machine.get_users
    @@users
  end
end

my_computer = Computer.new("Lo", 3555)

Look at the code above. Ruby is read top to bottom. So you are attempting to return @@users before it has even been defined as an object or assigned any key, value pairs.


#4

lmao. I did the "S" thing too!