xun su
11/30/2022, 5:47 PMinfo
as nullable
, why still got error?Vampire
11/30/2022, 5:48 PM= null
after the question markRobert Jaros
11/30/2022, 5:50 PMxun su
11/30/2022, 5:54 PMnull
, why I have to add the default value explicitly. 😅Vampire
11/30/2022, 5:55 PMnull
, but the invoker still has to decide what he wants to give. If you want the parameter to be optional in terms of being able to not specify it, you have to define a default value which can be null
but also any other valid value.Vampire
11/30/2022, 5:56 PMKlitos Kyriacou
11/30/2022, 5:59 PMfun foo(name: String, info: May<Int, Map<String, Any>>?) { ... }
fun foo(name: String) { ... }
Now you can call foo("bar", null)
and foo("bar")
and those are different things. The first is a null parameter, the second is no parameter.Vampire
11/30/2022, 6:42 PM