[fpc-pascal] String.Split(const Separators: array of Char; Options: TStringSplitOptions)
Michael Van Canneyt
michael at freepascal.org
Fri Sep 17 00:02:43 CEST 2021
On Thu, 16 Sep 2021, Bart via fpc-pascal wrote:
> Hi,
>
> I must be missing something obvious.
> But given the following definition of the Split() helper function for strings:
>
> Function Split(const Separators: array of Char; Options:
> TStringSplitOptions): TStringArray; overload; (fpc 3.2.2)
>
> Why does this not compile:
>
> var
> SA: TStringArray;
> ...
> SA := S.Split([#0..#32],TStringSplitOptions.ExcludeEmpty);
You are passing not an array of char but a set of char.
This works:
SA := S.Split(#0#32,TStringSplitOptions.ExcludeEmpty);
An array of char is a string.
But the message is indeed confusing. My guess is that the compiler decided
it was this overload;
function TStringHelper.Split( const Separators: array of Char;
AQuote: Char
):TStringArray; overload;
Michael.
More information about the fpc-pascal
mailing list