Why not @@users[@username] = @password?


#1

is there a difference between using values of initialize's arguments and instance variables?


#2

Was wondering about this, too. Doesn't seem to make a difference one way or another:

class Computer
    @@users = {}
    def initialize(username, password)
        @username = username
        @password = password
        @files = {}

        @@users[@username] = @password
    end

    def get_users
        puts @@users
    end
end

z = Computer.new("me", 123)
z.get_users

#3

As far as I can understand, they tie the argument into an actual instance variable - to make it reusable. I think it's also to adhere to the DRY principle.