We are familiar with fluent interfaces for calling methods in java and other programming languages. For eg:
Picasso.with(this).load(url).into(imageView);
>
Thanks to Zsmb13 and Christin for the answer, but if someone wants to use immutable fields I have another solution
data class Foo(val fooString: String = "", val fooInt: Int = 0) {
fun increaseTwo() = copy(fooInt = fooInt + 2)
fun increaseThree() = copy(fooInt = fooInt + 3)
}
And you can use it like this
println( Foo("foo",2).increaseTwo().increaseThree())
Output :
Foo(fooString=foo, fooInt=7)