The indexOf() with Record Type



Understanding IndexOf method with Record Type
Pas2JS pascal source code
type TRec = record x: Integer; y: string; end; { TApplication } procedure TApplication.RunApp; const r1: TRec = (x: 1; y: 'one'); r2: TRec = (x: 2; y: 'two'); r3: TRec = (x: 2; y: 'twobis'); var ints: array of Integer; recs: array of TRec; objs: array of TObject; begin Writeln('Integers'); // Integers ints.Add(1); ints.Add(2); Writeln(ints.IndexOf(0)); // -1 Writeln(ints.IndexOf(1)); // 0 Writeln(ints.IndexOf(2)); // 1 Writeln(ints.IndexOf(1,1)); // -1 Writeln(ints.IndexOf(2,1)); // 1 {-----} Writeln('Records'); // Records recs.Add(r1); recs.Add(r2); Writeln(recs.IndexOf(r1)); // 0 Writeln(recs.IndexOf(r2)); // 1 Writeln(recs.IndexOf(r3)); // -1 {-----} Writeln('Objects'); // Objects var o := New TObject; objs.Add(TObject.Create); objs.Add(o); Writeln(objs.IndexOf(TObject.Create)); // -1 Writeln(objs.IndexOf(o)); // 1