fluent

How to support a fluent style of programming in Scala

This is an excerpt from the Scala Cookbook (partially modified for the internet). This is Recipe 5.9, “How to support a fluent style of programming in Scala.”

Problem

You want to create an API so developers can write code in a fluent programming style, also known as method chaining.

Solution

A fluent style of programming lets users of your API write code by chaining method calls together, as in this example: