Quote:
Originally Posted by Devil_Lord2
You probably have and I still don't get it..
They just equal the same things in testing, unless I see an error of some kind giving physical evidence why it shouldn't be used I'll probably never fully understand. D:
|
PHP Code:
function onCreated()
{
temp.obj = new TStaticVar("SomeObject");
temp.one = new SomeObject();
temp.two = new SomeObject();
temp.one.asdf = "hi";
temp.two.asdf = "foo";
echo(format("Object one is '%s'", temp.one));
echo(format("Object two is '%s'", temp.two));
echo(format("Object keys: '%s', '%s'", temp.one.asdf, temp.two.asdf));
// Compare the objects as objects
if (temp.one == temp.two)
echo("Objects are the same");
else
echo("Objects are different");
// Compare the objects after being coerced to strings
if (@temp.one == @temp.two)
echo("Object names are equal");
else
echo("Object names are different");
}
Output:
NPC Code:
Object one is 'SomeObject'
Object two is 'SomeObject'
Object keys: 'hi', 'foo'
Objects are different
Object names are equal
When the objects are coerced into strings, you get the object names only typically. In this example, it results in two objects appearing to be the same (because their
object names are the same) even though we have just proven them to be different.
This is something you
MUST be aware of when coercing objects into strings in GScript. It doesn't always work how you expect.