5. Getting More Creative

<PLEASE USE THE FOLLOWING TEMPLATE TO HELP YOU CREATE A GREAT POST!>

<Below this line, add a link to the EXACT exercise that you are stuck at.>
https://www.codecademy.com/courses/ruby-beginner-en-X5wcR/0/5?curriculum_id=5059f8619189a5000201fbcb#

<In what way does your code behave incorrectly? Include ALL error messages.>
It turns nil only. I can’t see the message which I wrote as puts “New file #{filename} was created by #{@username} at #{time}”. What is wrong here? Can someone give me any idea?

``` class Computer @@users = {} def initialize(username,password) @username = username @password = password @files = {} @@users[username] = password end def create(filename) time = Time.now @files = Hash.new("files") files={"Serra" => 1234} @files[filename] = time puts "New file #{filename} was created by #{@username} at #{time}" end end ```

We would not write this directly in the code. This is a helper method for use by an instance.

serra = Computer.new("Serra", 1234)
serra.create("my_new_file.txt")

Output

my_new_file.txt was created by Serra at 2016-07-26 17:21:59 +0000.
nil
1 Like

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