with the named arguments and default arguments, do...
# announcements
g
with the named arguments and default arguments, do you still use the pattern builder in Kotlin ?
👌 5
d
@gaspard The builder patten is useful when interoperating with Java and when making DSLs.
c
Same here - when providing API to Java or DSL.
p
I've only just started on Kotlin and I'm ploughing through Kotlin in Action. In there they say you can use apply() to do what is often achieved by a builder in Java. I've found it useful when creating objects from Java classes where they don't have named arguments or default values on constructors (eg where you have a pojo with a single default constructor).
c
Yes that is a common use case for
apply {}
indeed. If the pojo is written in Kotlin though and isn't expected to be used from Java a lot, it is usually more appropriate to use named arguments.