can’t help feeling there should be a way to reduce...
# getting-started
b
can’t help feeling there should be a way to reduce the duplication of class name.
m
You can write
fun Int.r() = RationalNumber(this, 1)
. Kotlin will infer the return type of the function when you use
=
.
b
Thanks …. hacking away, I just discovered that … I didn’t know it was related to the
=
however. 👍
m
When you write a function with brackets without the return type, like
fun f() { ... }
, Kotlin will always infer the return type to be
Unit
.
b
@marstran thanks