Hullaballoonatic07/02/2019, 9:52 PM
class Foo<A, B>(val a: A, val b: B) where A: Bar, A: Baz
class Foo<A: Bar & Baz, B>(val a: A, val b: B)
is getting any use in Kotlin anyhow...
To allow for
fun <N: Byte | Int | Float | Double> areaByMetres(length: N, width: N) = Area(length.toDouble().metre, width.toDouble().metre)
to accept any number type that can be safely cast up to Double for either of its params would take 8 more declarations of the function. If we were doing this for volume, then it would take 27 more. Yikes! Of course allowing for multiple possible types has a lot more ramifications, and I imagine would be very difficult to add to a strongly typed language, and is arguably no longer strongly typed.
kevinmost07/02/2019, 9:57 PM
karelpeeters07/02/2019, 9:58 PM
Hullaballoonatic07/02/2019, 9:58 PM