Neslib.Yaml icon indicating copy to clipboard operation
Neslib.Yaml copied to clipboard

TYAMLNode Question

Open gorepj opened this issue 10 months ago • 2 comments

Why/How does this assignment work?

var MyYAMLNode: TYAMLNode; //Line 1 var iValue: integer = MyYAMLNode; //Line 2 var sValue: string = MyYAMLNode; //Line 3

With records that I declare line 2 would give me a "Incompatible types "Integer" and "TMyRecord" With records that I declare line 3 would give me a "Incompatible types "String" and "TMyRecord"

gorepj avatar Apr 11 '25 04:04 gorepj

This is because TYamlNode has various overloaded implicit operators. For example:

type
  TYamlNode = record
  ...
    class operator Implicit(const ANode: TYamlNode): Int32; inline; static;
  end;

This operator implicitly converts a TYamlNode to an integer. See Operator Overloading (Delphi) for more information about operator overloading.

neslib avatar Apr 15 '25 15:04 neslib

Thank you very much Eric. That life - long mystery is now solved for me. Have a great day.

gorepj avatar Apr 16 '25 09:04 gorepj