Hello Community,
when I convert an object instance to a string with Std.string() and when I try to apply an
EReg on it, to find what is inside the curly brackets, only crap comes out.
I have simplified this phänomenon by simply applying an EReg that is supposed to show the whole string.
Applying this to an object representation, it just returns one curly bracket
{ , while applying it to the same string that was manually written, it returns the complete string, as it is supposed to.
See my
example.
Does anybody can tell me, what I am doing wrong?
Technically? Conceptionally? Logically?
Kind regards
Arnim
What I am intending to do:
I want to compare instanced objects. The mashine is only supposed to compare the equality of the values of each instance. No need to know if they are the same instances.
So far, so good and so easy.
Simply make them a string and compare them:
if (Std.string( objX ) == Std.string( objY ) )
doSomething();
But regrattably it is not as simple as that.
If the order of initializations of the fields differs, also the resulting strings differ:
objX.int = 13
objX.string = "Great"
Std.string( objX )
leads to--> { int : 13, string : Great }
AndobjY.string = "Great"
objY.int = 13
Std.string( objY)
leads to--> { string : Great, int : 13 }
So, although the value of each field is equal, the comparison would return 'false'.