I am trying to create an extension as a property and I experimented with an extension function as well, below an example for BigDecimal
:
val BigDecimal.HUNDRED: BigDecimal
get() = TEN.multiply(TEN)
fun BigDecimal.HUNDRED_ONE(): BigDecimal {
return TEN.multiply(TEN)
}
It seems that Kotlin recognizes neither HUNDRED
nor HUNDRED_ONE()
. I am using Kotlin version 1.5.21
.
Am I doing anything wrong on Kotlin version 1.5.21
that doesn't work correctly?
I have used this functionality before for lists. For instance:
fun <T> toList(list: List<T>?): List<T> {
return list ?: listOf()
}