6. Scope it Out - i need to know about @@Files


#1

i need some explanation about @@files here:

class Computer
    $manufacturer = "Mango Computer, Inc."
    @@files = {hello: "Hello, world!"}
    def initialize(username, password)
        @username = username
        @password = password
    end
    def self.display_files
        @@files
    end
end

is the block of @@files in Symbol ?
and why is it generate this form {:hello=>"Hello, world!"} it as if it a SymbolHash data
if not, then what is this type of data ?

also a second question: what is Self ?
i search the internet for a clear answer but i can't find any
what it's exactly do ?
is it a form of yield but for class ?

thank you in advance


#2

In Ruby, @@ symbolizes a class variable. Every new instance of the class will share this variable. @ symbolizes an instance variable. Every new instance will have their own.


#3

@a7lamlover,
Try a google search
ruby self explained site:stackoverflow.com
for instance
http://stackoverflow.com/questions/35117203/what-does-self-mean-in-ruby
http://stackoverflow.com/questions/873889/ruby-definition-of-self

OR
ruby instance variable explained site:stackoverflow.com
http://stackoverflow.com/questions/15773552/ruby-class-instance-variable-vs-class-variable
=or=
ruby class variable vs instance variable site:stackoverflow.com
http://stackoverflow.com/questions/7329954/instance-variable-class-variable-and-the-difference-between-them-in-ruby

OR
ruby getter vs setter method site:stackoverflow.com
http://stackoverflow.com/questions/5046831/why-use-rubys-attr-accessor-attr-reader-and-attr-writer

OR
http://stackoverflow.com/questions/28733398/understanding-hashes


#4

thank you all for your nice replay