concept flow typing in category groovy

appears as: flow typing
Groovy in Action, Second Edition

This is an excerpt from Manning's book Groovy in Action, Second Edition.

In the previous sections, we’ve spent time explaining what @TypeChecked would offer you, and what it would prohibit, but we also explained why it was difficult to perform static analysis of a dynamic language. The semantics of a dynamic program are difficult, if not impossible, to determine at compile time, meaning that the type checker might think that one method will be called, but in reality, another one would be. To reduce the gap between the dynamic and the static behavior, the type inference engine uses the principle of flow typing.

Flow typing is the ability to determine the type of a variable at some point in the code, depending on the previous assignments. The next listing contains a series of assignments that change the runtime type.

Listing 10.34. Type hierarchies and flow typing
sitemap

Unable to load book!

The book could not be loaded.

(try again in a couple of minutes)

manning.com homepage
test yourself with a liveTest