What do you expect is the output?
What do you expect is the output?
var
v: TValue;
begin
v := 'Hello world';
Writeln(v.IsType);
Writeln(v.IsType);
Writeln(v.IsType);
end;
When working on a fix for http://qc.embarcadero.com/wc/qcmain.aspx?d=107906 I noticed that IsType just calls TryCast and thus IsType returns true for any type it can convert to Variant.
http://qc.embarcadero.com/wc/qcmain.aspx?d=107906
var
v: TValue;
begin
v := 'Hello world';
Writeln(v.IsType
Writeln(v.IsType
Writeln(v.IsType
end;
When working on a fix for http://qc.embarcadero.com/wc/qcmain.aspx?d=107906 I noticed that IsType
http://qc.embarcadero.com/wc/qcmain.aspx?d=107906
I would expect True, False, False.
ReplyDeleteTrue, False, False.
ReplyDeleteGiven its implementation IsType should rather be named "IsCastableToType" or "IsCompatibleWithType"
I'm too lazy -- what is the output?
ReplyDeleteNick Hodges True, False, True (!) because TryCast returns True when casting a compatible type to Variant (well, except Boolean as in the mentioned bug which is why I found that)
ReplyDeleteMarco Cantù XE4 has a "kind of" fix for the above mentioned bug (no exception anymore) but it does cast every enumeration to Int64 and puts that into the Variant.
ReplyDelete