O'Reilly logo

Delphi Cookbook - Second Edition by Daniele Teti

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

Duck typing using RTTI

 

"When I see a bird that walks like a duck and swims like a duck and quacks like a duck, I call that bird a duck."

 
 --James Whitcomb Riley

Clear, isn't it? What may not be so clear is that this approach can be used also in computer programming. Yes, even without an actual duck!

Getting ready

Referring to duck typing, Wikipedia gives the following explanation (http://en.wikipedia.org/wiki/Duck_typing).

In computer programming with object-oriented programming languages, duck typing is a style of typing in which an object's methods and properties determine the valid semantics, rather than its inheritance from a particular class or the implementation of an explicit interface.

How can all these concepts be used in everyday programming? ...

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