I have a weird situation and I was wondering if anyone has a solution. I have a couple data classes from a shared library that are structured very similarly.
data class Foo(val width: Float, val height: Float, val x: Float, val y: Float)
data class Bar(val width: Float, val height: Float, val x: Float, val y: Float)
To construct them, I have to write something like
when(clss)
is Foo -> constructFoo()
is Bar -> constructBar()
with each of those construct methods doing the exact same thing (setting the same variable names & types). Is there a structure or something in Kotlin that I can use to make this cleaner?