Andrew Gazelka
07/19/2019, 5:40 AMAny
extend Unit
? This would be nice for overriding functions…PHondogo
07/19/2019, 6:35 AMkarelpeeters
07/19/2019, 7:31 AMUnit
doesn't really mean void
, instead all functions actually return the single Unit
object.Any
extending Unit
doesn't really make sense, since Unit
is just an ordinary class.Dico
07/19/2019, 8:09 AMPHondogo
07/19/2019, 8:18 AMkarelpeeters
07/19/2019, 8:22 AMinterface Test {
fun foo()
}
class MyTest: Test {
fun bar() = 5
override fun foo() = bar()
}
Or be able to pass a () -> String
to something expecting () -> Unit
. The JVM bytecode could still be generated the same way, so no performance impact.PHondogo
07/19/2019, 8:37 AMDico
07/19/2019, 9:07 AMx is Unit
will always be true then so introducing such mechanism would be backward incompatibleRuckus
07/19/2019, 1:32 PMfoo
is equivalent to function bar
, but it's not.fun a() = b()
and fun a() { b() }
, even when they are technically the same. (i.e. when both return Unit
)karelpeeters
07/19/2019, 6:06 PM::foo
because it happens to return something.Ruckus
07/19/2019, 6:12 PM