Jimmy lim wrote:Thanks Junilu, I am trying to write out each statement to understand what each line means. however I am having trouble figuring out how does y = 4 in this example? wouldn't y = 27? since y=x.
No. Think of it like this:
Say there's you and a friend. You're y and your friend is x.
I'm going to give your friend $4. That's like x = 4.
Then I'm going to give you however much your friend has. That's like y = x.
Now I'm going to give your friend $27. That's like x = 27 (the $4 I gave him previously magically disappears).
How much do
you have now? $27 or $4? You still have $4, right? So me giving your friend a new amount didn't affect what you have. The same principle applies with the assignment statements you're confused about.