File tree Expand file tree Collapse file tree 3 files changed +10
-8
lines changed Expand file tree Collapse file tree 3 files changed +10
-8
lines changed Original file line number Diff line number Diff line change 88 Name : string;
99 end ;
1010
11- TAppleList = specialize TObjectList<TApple>;
11+ TAppleList = { $ifdef FPC_OBJFPC } specialize { $endif } TObjectList<TApple>;
1212
1313var
1414 A: TApple;
Original file line number Diff line number Diff line change 1818 Name : string;
1919 end ;
2020
21- TAppleList = specialize TObjectList<TApple>;
21+ TAppleList = { $ifdef FPC_OBJFPC } specialize { $endif } TObjectList<TApple>;
2222
2323function CompareApples (
2424 { $ifdef GENERICS_CONSTREF} constref{ $else} const { $endif}
2828end ;
2929
3030type
31- TAppleComparer = specialize TComparer<TApple>;
31+ TAppleComparer = { $ifdef FPC_OBJFPC } specialize { $endif } TComparer<TApple>;
3232var
3333 A: TApple;
3434 L: TAppleList;
4747 A.Name := ' 22' ;
4848 L.Add(A);
4949
50- L.Sort(TAppleComparer.Construct(@ CompareApples));
50+ L.Sort(TAppleComparer.Construct({ $ifdef FPC_OBJFPC } @ { $endif } CompareApples));
5151
5252 Writeln(' Count: ' , L.Count);
5353 Writeln(L[0 ].Name );
Original file line number Diff line number Diff line change 5353
5454procedure UseInterfaces ;
5555begin
56- if C1 is IMyInterface then
57- // if Supports(C1, IMyInterface) then // equivalent to "is" check above
56+ // In FPC, you could also check using "is", like:
57+ // if C1 is IMyInterface then ...
58+
59+ if Supports(C1, IMyInterface) then
5860 UseThroughInterface(C1 as IMyInterface);
59- if C2 is IMyInterface then
61+ if Supports(C2, IMyInterface) then
6062 UseThroughInterface(C2 as IMyInterface);
61- if C3 is IMyInterface then
63+ if Supports(C3, IMyInterface) then
6264 UseThroughInterface(C3 as IMyInterface);
6365end ;
6466
You can’t perform that action at this time.
0 commit comments