Conor Fennell
03/11/2021, 5:30 PMdata class Calculation(
val money: Double,
val multiplier: Double,
)
fun Calculation.total(): Double = money * multiplier
OR
data class Calculation(
val money: Double,
val multiplier: Double,
) {
fun total(): Double = money * multiplier
}
wbertan
03/11/2021, 5:44 PMdata class Calculation(
val money: Double,
val multiplier: Double,
) {
val total: Double
get() = money * multiplier
}
wbertan
03/11/2021, 5:45 PMCalculation
is required, I would put inside Calculation
. If it would be in only one specific module, I would make an Extension with visibility only in that module.elizarov
03/12/2021, 6:01 AMtotal
is conceptually a part of Caculation
or just an utility. See https://elizarov.medium.com/extension-oriented-design-13f4f27deaee