How value of x and y after updated be 13 of both of them @tarunluthra
After 01:15:00 this in webinar
Hello @Nikhil-Aggarwal-2320066674901389,
A reference variable is an alias, that is, another name for an already existing variable. Once a reference is initialized with a variable, either the variable name or the reference name may be used to refer to the variable.
Let’s understand this with an example.
Your name is Nikhil.
Nikhil had 10 toffees: x=10
I call you Nik: &y=x
I gave 1 toffee to Nik: y=y+1
Then, CB gave Nikhil a toffee: update(x)
Also, CB gave Nik a toffee: update(y)
So, at each operation if Nikhil is getting extra toffee.
Then, it is also true say that Nik is also got extra toffee as both are names of same person.
Same is the case with reference variable.
Hope, this would help.
Give a like, if you are satisfied.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.