O'Reilly logo

Expert Delphi by Paweł Głowacki

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Generics

One of the most powerful concepts in the Object Pascal language is a generic type. This way, we can write our code in a more generic way, so the same algorithm can operate not on just one data type, but many. Generics are things that can be parameterized by type. The code is not fully specified, providing the implementation details to the code that uses generics. There could be generic types where the whole type definition is parameterized by an unknown type, or we can just define generic methods that operate on a type that is not fully specified.

As an example, let's consider a fillable class. Many languages have the concept of nullable values, but we will be different and use "fillable". It seems more natural. One useful example ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required