Tarun
03/13/2018, 11:01 AMfun callApi(@NonNull context: Context) : String{
return "hello world!"
}
Andreas Sinz
03/13/2018, 11:05 AMContext
is already not nullable, so the annotation is superfluousTarun
03/13/2018, 11:09 AMfun callApi( str: String) : String{
return "hello world!"
}
specify non null String parameter
and following code :
fun callApi( str: String?) : String{
return "hello world!"
}
means a nullable string parameter.
does this makes annotations for function arguements useless?Andreas Sinz
03/13/2018, 11:14 AM@NonNull
or @Nullable
obsolete in kotlin code, yes. These things are backed into the Typesystem. https://kotlinlang.org/docs/reference/null-safety.htmlTarun
03/13/2018, 11:16 AM