Is it possible to access copy function of data cla...
# getting-started
s
Is it possible to access copy function of data class in Java with optional parameters? e.g I want to change a3 in Java. What is the best way to do it considering my class A is immutable. Should I write setter method which internally should do a copy by updating the required value or is there any other option?
d
Since java doesn't support named/optional parameters, you'll have to make a custom copy function in kotlin for java.
Copy code
fun copyWithA3(a3: Int) = copy(a3 = a3)
👍 2
s
Thanks.
d
No problem.