jvm - What is Unit Object in Kotlin -
this question has answer here:
right learning kotlin, in guide run these 2 methods, 1 withunit
, 1 doesn't
method withunit
fun printsum(a: int, b: int): unit { println("sum of $a , $b ${a + b}") }
method without unit
fun printsum(a: int, b: int) { println("sum of $a , $b ${a + b}") }
my question is, unit
actually? void
in java? if it's void
why 1 of method above doesn't have unit
run fine.
which 1 should use when want method returning nothing? , when best time use unit
.
anyone can explain? cause it's confusing me. in advance.
yes.it mentioned in website @ github source that
object unit
type 1 value: unit object. type corresponds void type in java.
also in repository,
/** * type 1 value: unit object. type corresponds
void
type in java. */
Comments
Post a Comment