[fpc-pascal] Option type

denisgolovan denisgolovan at yandex.ru
Tue Jun 1 20:56:01 CEST 2021



> You need to use a constraint like:
> 
> type
> generic TOption<T: TObject> = record
> case IsSome:boolean of
> true: ( some: T );
> false: ();
> end;
> 
> Not sure why though.
> 
> Regards,
> Ryan Joseph

That would limit supported types to class instances.
I'll like to avoid that. 
Ideally TOption type should allow any type (primitives, strings, objects, class instances, etc).

-- Regards,
Denis Golovan


More information about the fpc-pascal mailing list