is there a name for this syntax? ```myCollection ...
# announcements
r
is there a name for this syntax?
Copy code
myCollection
    .map { ... }
    .filter { ... }
    .forEach { ... }
I know in Java i would call it “stream syntax” but that’s because there you actually need to create streams before being able to make these calls
m
it’s not specific to Streams, it’s called “fluent API” https://en.wikipedia.org/wiki/Fluent_interface
👍 3
r
s
Maybe unrelated: What’s the design patterns one would use for achieving this? Decorators?
m
no, in Java and similar would be the Builder pattern, and DSL builders in Kotlin
s
Fluent makes sense, I know this terminology from C# LINQ and folks use this I think
ah yes, Builder would make more sense actually 🥵
m
@Rainer Schlonvoigt yeah, but chaining is just a “tool”, “fluent interface” is the concept or pattern, it encompasses it
👍 2
s
if somebody cares
👍 1
m
Cool, thanks. Speaking of the builder pattern, there is a nifty variation that I like but it’s little known: https://www.endoflineblog.com/type-safe-builder-pattern-in-java-and-the-jilt-library a more advanced use of fluent interfaces
s
Interesting.
👌 1