<How to prevent computing the same initialisation ...
# stackoverflow
u
How to prevent computing the same initialisation over and over again? I have the following data class: data class State(val property1: Type1, val property2: Type2, ...){ companion object Factory { fun initialise (val data : Data){ val property1 = ... //some computation val propery2 = ... //some other computation return State(propert1,property2) } } } The problem is that I will call the initialise function a lot in my code (I have an algorithm that define a state variable, change it but at some...