Confused with objects in Ruby
- by David
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?