I'm not sure if this has been discussed (or even i...
# language-proposals
r
I'm not sure if this has been discussed (or even if it's a good idea for that matter), but I ran across a case where it would be nice to have some sort of cast overloading. Something like the following:
Copy code
// Something like this, but please not exactly like this
operator fun ObservableInt.cast(Int::class) = get()
operator fun ObservableInt.cast(Double::class) = get().toDouble()
...
fun updateGrid(rows: Int, cols: Int) { ... }
fun updateBounds(width: Double, height: Double) { ... }
...
val rows: ObservableInt = ...
val cols: ObservableInt = ...
val width: ObservableInt = ...
val height: ObservableInt = ...
...
updateGrid(rows as Int, cols as Int)
updateBounds(width as Double, height as Double)
Not that the cast is still explicit (requiring
as
). I really do NOT want implicit casts.
👍🏼 1