https://kotlinlang.org logo
#announcements
Title
# announcements
p

passsy

07/25/2017, 11:12 PM
Just wrote my first DSL in kotlin. I’m a little sad that the resulting object cannot be immutable.
a

artem_zin

07/25/2017, 11:19 PM
YES, this. What you can do though is treat DSL as a neat builder and then actually have
.build()
etc
Which will return immutable data class
p

passsy

07/25/2017, 11:26 PM
consider a html DSL, every object must have a immutable representation. I implemented this but it requires so much code.
a

artem_zin

07/25/2017, 11:27 PM
I know right 😞
v

voddan

07/26/2017, 6:05 AM
you could have setters that produce a new immutable state instead of modifying the current one
4 Views