i'm having an argue with my friend.
Is:
public class Thing
{
private Thing s;
public void foo(Thing t)
{
s = t;
t.s = this;
}
}
The same as:
public class Thing
{
private Thing s;
public void foo(Thing t)
{
s = t;
s.s = this;
}
}
I think its the same since s is set to t in both cases, but he disagrees
They're the same since you're setting them to the same reference.
However, if you had two uses of new
then the references would be different, and then your friend would be correct.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With