Very simple proposal. Add an extension function to...
# language-proposals
j
Very simple proposal. Add an extension function to
Double
so you can do this:
0.5.toBigDecimal()
r
Isn't it considered bad practice to create a BigDecimal from a Double or Float?
o
You can create an extension property:
Copy code
val <http://Double.bd|Double.bd> : BigDecimal get() = BigDecimal(this)

val value = 0.5.bd
👎 1
👍 1
d
I'd prefer it as
fun Double.toBigDecimal()
, because that's a conversion function, just like
toMutableList
.
r
@dmitry.petrov Isn't that what's coming in 1.2?
d
Yes it is. Just explained what I don't like about
.bd
r
Ah, sorry. I though you were responding to @elizarov, so I got a bit confused.