Hi, I wrap my head around a problem. I want to bui...
# android
l
Hi, I wrap my head around a problem. I want to build a data class in relation to specific conditions. For instance:
Copy code
data class Test(val test1: Int, val test2: Int)
This would be the base and if a specific condition is satisfied:
Copy code
data class Test(val test1: Int, val test2: Int, val test3: Int)
I could create 2 separate data classes but then I always have to pass both and I'd like to deal only with one data class. Does someone has an idea?
👍 1
r
I think you can make the third field nullable.
r
data class Test(val test1: Int, val test2: Int, val test3: Int? = null)
d
make third field optional by giving it a default value..
l
The problem is that it won't be just 1 field but rather 5-10 fields and there are more than 1 condition