gabrielfv
08/15/2017, 8:02 PMfun foo(bar: Int?) can be called like foo(), instead of having to write fun foo(bar: Int? = null). I see people comonly reading the ? as sort of "opitional" in this context, and I don't see the point of calling foo(null), though makes some sense when
val a: Int? = mayReturnInt()
foo(a)
which is also a common scenarioumar
08/15/2017, 9:36 PMgabrielfv
08/15/2017, 9:40 PM? operator they could be null by default, and there'd be no other possibility for a default value, unlike 0 for Int or "" for String.gabrielfv
08/15/2017, 9:42 PM? makes it very clear that a value can be null. That's it's role after all.gabrielfv
08/15/2017, 9:46 PMfun foo(a: Int? = 0) can accept foo(null), with a actually being null and foo() with a being 0.gabrielfv
08/15/2017, 9:48 PMfun foo(bar: Int) would not be passive of being called foo() and would break is not a different behavior, but could be due to the fact that bar could not be null and therefore there is no way to infer anything.benleggiero
08/16/2017, 1:53 AM? means "optional parameter", not "nullable and optional". I can imagine newcomers thinking that Kotlin only allows omitted optional parameters to be null and not bothering to discover the = syntaxbenleggiero
08/16/2017, 2:30 AMgabrielfv
08/16/2017, 4:50 AMgabrielfv
08/16/2017, 4:52 AMfoo(null) explicitly? Is there any example?umar
08/16/2017, 6:07 AMnull?