Am 13.12.2017 02:37 schrieb "Fabio Luis Girardi" <fluisgira...@gmail.com>:
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 The problem is not the operator, but the array: before 3.1.1 the "[...]" operator if used outside a parameter that is an open array *always* generates a set. This only changed in trunk a few months ago so that the operator can be used as an array constructor as well. So for now you'd need to use an array variable on the right side. Regards, Sven
_______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal