What's wrong with my code? 7/8


#1

https://www.codecademy.com/courses/ruby-beginner-en-X5wcR/0/7

Can somebody tell me what's wrong with my code please? I've been comparing with others but I can't see why mine won't work...

   class Computer
  @@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 Computer.get_users
    @@users
  end
end

my_computer = Computer.new("Morgane", 01234)

#2

Your code works as expected.

my_computer = Computer.new("Morgane", 01234)
puts Computer.get_users()
my_computer.create('new_file.txt')

Console output

{"Morgane"=>668}
new_file.txt was created by Morgane at 2017-05-03 21:05:05 +0000.
nil

#3

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