Duck typing alternatives

As you can see from the preceding code, duck typing saves us from some extra code writing and the need to define common interfaces. Other ways to achieve the same would involve creating wrappers, which implement a common interface.

Get Scala Design Patterns - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.