+ 2
What happens if I assign a variable x to 8, and Y to x, can i later change what value x holds? Or is Y forced to be equal to 8?
Hopefully the question is clear enough.
4 Antworten
+ 12
Yes, you can change the value whenever you want.
x = 8
y = x
y = 10
puts x # 8
puts y # 10
+ 10
And what would be the difference? Ruby is case sensitive, but if you write "Y" instead of "y" you will have the same output in this case. :3
+ 1
firstly you can't assign a variable to any constant, reverse though!
now
x= 8;
y=x
x=9;
see you can change the value assigned to x, but y has the same value of x previously assigned i.e 8
if you print the vars, you get x=9 y=8
0
I'm saying if Y is capitalized