In an video, I saw the syntax
val one = 1.bd
but it doesn’t work for me. So I defined
fun Int.bd() : BigDecimal? = BigDecimal(this)
and now I can write
val one = 1.bd()
Nice, but according to what I read, parentheses are optional, but it doesn’t work. Are parentheses mandatory or what’s gong on here?
B7W
2
hello,
Look this example http://kotlin-demo.jetbrains.com/?publicLink=114553589811306443494-1930716178
What you want is extension properties. You declared extension method. Read details here http://kotlinlang.org/docs/reference/extensions.html
About optional parentheses. I think you mean infix notation. Read details here http://kotlinlang.org/docs/reference/functions.html
Look this example http://kotlin-demo.jetbrains.com/?publicLink=114553589811306443494-1930716178
What you want is extension properties. You declared extension method. Read details here http://kotlinlang.org/docs/reference/extensions.html
Perfect. I’re read about extension properties, but have forgotten it all.
About optional parentheses. I think you mean infix notation. Read details here http://kotlinlang.org/docs/reference/functions.html
That’s it.
I’ve seen that a question has been marked as answered, but I don’t see how?
unodgs
4
val Int.bd:BigDecimal get() = this.toBigDecimal()