Antoine Gagnon
06/15/2020, 2:01 PMfun getString(key: String?, default: String?): String?
The issue is that I’m trying to make it so that the compiler can tell if the default is null or not, and make the return type null or not.
I’ve tried doing this:
fun <T:String?>getString(key: String?, default: T): T
But if the default is value null
, the inffered type becomes Nothing?
instead of String?
Any idea on how to do this properly?Luis Mirabal
06/15/2020, 2:20 PMfun getString(key: String?, default: Nothing?): String?
fun getString(key: String?, default: String): String