robstoll
05/11/2018, 1:02 PMfun foo(s: String?){}
is there a way to force that one has to pass String?
and cannot pass String
?adam-mcneilly
05/11/2018, 1:02 PMString
you're treating it as a nullable inside your function. I'm not sure you need to force the caller to do anything.robstoll
05/11/2018, 1:03 PMadam-mcneilly
05/11/2018, 1:03 PMrobstoll
05/11/2018, 1:04 PMrobstoll
05/11/2018, 1:04 PMadam-mcneilly
05/11/2018, 1:05 PMadam-mcneilly
05/11/2018, 1:06 PMrobstoll
05/11/2018, 1:06 PMnull == "hello"
so if you know that left hand side might be null then you might not do ==
but take another actionadam-mcneilly
05/11/2018, 1:08 PMrobstoll
05/11/2018, 1:09 PMnull
as your error code then null == "hello"
has semantically a different meaning than "ciao" == "hello"
robstoll
05/11/2018, 1:10 PMrobstoll
05/11/2018, 1:10 PMadam-mcneilly
05/11/2018, 1:10 PMadam-mcneilly
05/11/2018, 1:12 PMrobstoll
05/11/2018, 1:13 PMadam-mcneilly
05/11/2018, 1:13 PMrobstoll
05/11/2018, 1:13 PMadam-mcneilly
05/11/2018, 1:13 PMrobstoll
05/11/2018, 1:14 PM==
robstoll
05/11/2018, 1:14 PMrobstoll
05/11/2018, 1:14 PMfoo
adam-mcneilly
05/11/2018, 1:15 PMrobstoll
05/11/2018, 1:15 PMfoo
and it is nullable, then he will get an error (because foo
is not applicable to nullable`) and will instead see fooNullable
as available optionadam-mcneilly
05/11/2018, 1:15 PMadam-mcneilly
05/11/2018, 1:15 PMadam-mcneilly
05/11/2018, 1:15 PMadam-mcneilly
05/11/2018, 1:16 PMadam-mcneilly
05/11/2018, 1:16 PMadam-mcneilly
05/11/2018, 1:17 PMrobstoll
05/11/2018, 1:17 PM