4 ms·
This would be nice for situations where you have a lot of method calls daisy chained together. Like builders or Java Streams. DoThing() .withSomeOtherThi
by Igelau 6y ago
This would be nice for situations where you have a lot of method calls daisy chained together. Like builders or Java Streams.
DoThing()
.withSomeOtherThing()
.onSundays()
.withCharset(Blah.BLAH)
.betterAddThis(x -> { ret stuff() })
.build()
=> turducken
The whole assembly of the variable 'turducken' is drifting rightward. By the end we want to get to the point rather than backtrack.
- kazinator 6y agoIt's possible to have a language design like this: DoThing() .withSomeOtherThing() .onSundays() .withCharset(Blah.BLAH) .betterAddThis(x -> { ret stuff() }) .build() .into(turducken) Where a.into(b) is really (into a b), which is a macro sugar for (set b a) and not a function.