I have java code that uses the pattern of say Inqu...
# getting-started
s
I have java code that uses the pattern of say Inquiry().status(sts).notes(blah). Which enables chaining. what can i do from a kotlin aspect to define a similar class as that? the fields are not required, so you may want to set only 2 of those 3
@Ruckus ah, what if you are using the ctor members? e.g. class Inquiry( val status: String? = null, ...)
just add the function in the brackets of the class, right?
ah. that does get rid of the constness sadly 😕
right. guess i was trying to get the benefits of the constness but mabye it's just causing too many issues here
indeed, i understand
right but those are unusuable if you go the const route
as i understand it?
yeah, that's why i was trying to bridge the gap between writing it differently and weighing the costs/downsides of writing it the 'correct' way
v
Or you make it a data class and use the
clone
method in the chain methods
e
the common patterns in Kotlin are either named arguments, or a builder/scope such as
Copy code
Inquiry {
    status = sts
    notes = blah
}.doSomethingWithStatus()
when there are concerns about binary compatibility