The indexOf() with Function Pointer



IndexOf with Function Pointer
Pas2JS pascal source code
type TProc = procedure; type IMY = interface procedure Dummy; end; type TMy = class(IMy) procedure Dummy; begin end; class procedure CDummy; begin end; end; procedure test; begin { just to test it out } end; { unit1.pas } var m := New TMy; i := m; a: array of TProc; begin a.add(test); a.Add(TMy.CDummy); a.Add(m.Dummy); a.Add(i.Dummy); Writeln(a.IndexOf(test)); // 0 Writeln(a.IndexOf(nil)); // -1 Writeln(a.IndexOf(@test)); // 0 Writeln(a.IndexOf(TMy.CDummy)); // 1 Writeln(a.IndexOf(m.Dummy)); // 2 Writeln(a.IndexOf(i.Dummy)); // 2 Writeln(a.IndexOf(i.Dummy, 3)); // 3