Challenges in Building for Fluency

Building fluency into code takes some effort. Explore if an extension function will be useful. Sometimes an infix method may help remove some clutter in code—to get rid of the dot and parenthesis. Maybe an implicit receiver will come to the rescue. You can choose from a number of techniques, and sometimes they may appear to conflict with one another. Let’s look at an example of this situation.

To use the infix notation, so you can remove the dot and parenthesis, you need an object reference. For instance, a person reference is needed to use infix notation to make the following fluent: person run "fast". But by using an implicit reference to the instance of this hypothetical Person class, we can get rid of the ...

Get Programming Kotlin 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.