Chapter 3Dynamic Typing
In dynamic typing, at runtime types are inferred and methods and their arguments are checked. With this ability, we can inject behavior into classes at runtime, making the code more extensible than with strict static typing.
In this chapter you’ll learn the benefits of dynamic typing and how to use it in Groovy. With dynamic typing, as you’ll see, we can create flexible design with less code than in Java. With the ability to defer arguments’ type verification to runtime, polymorphism in Groovy is on steroids. With the multimethods tool, we can provide alternate behaviors to operations based on the arguments’ runtime types. We’ll cover how to keep these powerful features under control using the static compilation ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access