Confused with objects in Ruby
        Posted  
        
            by 
                David
            
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by David
        
        
        
        Published on 2011-02-01T22:14:26Z
        Indexed on 
            2011/02/01
            23:25 UTC
        
        
        Read the original article
        Hit count: 224
        
ruby
Ruby Newbie here,
I understand that everything is an object in Ruby, one thing that I wasn't sure about was understanding Variables. Variables basically give reference to objects (correct me if I'm wrong). During an instructional video, the teacher did a demonstration which went as below:
(irb)
a = 100
==> 100
b = a
==> 100
b
==> 100
This part I get, makes total sense.
Then he did
a = 50
==> 50
b
==> 100
If B is supposed to point to what a was set which was a 100, why does b still point to 100 if a has now been set as 50?
© Stack Overflow or respective owner