Hi all!
I want to extend some operators in Freepascal. I want to achieve something like this:
if aStr in ['string item 1', 'string item 2', 'string item 3'] then
...
else
...;Following the examples to overload operators, I wrote:
operator in (a:String; b:array of string):Boolean;
var
c: Integer;
begin
Result:=false;
for c:=0 to High(b) do
if b[c]=a then begin
result:=true;
exit;
end;
end;But when I try compile this piece of code:
if aStr in ['string item 1', 'string item 2', 'string item 3'] then
...
else
...;I got:
Error: Ordinal expression expected
Looking to Freepascal documentation, IN operator overloading is possible:
https://www.freepascal.org/docs-html/ref/refse104.html
So if the overloading is possible, Is possible to get this example working?
