is it possible to do something like:
/**
* Converts all of the characters in the string to upper case.
*
* @param str the string to be converted to uppercase
* @return the string converted to uppercase or empty string if the input was null
*/
fun String?.toUpperCase(): String = this?.toUpperCase() ?: ""
- What would this do? It would make
toUpperCase
null safe. - What problem am I having? the return value,
this?.toUpperCase()
, refers to the extension function
Is the only option to rename my extension function or is there a way to refer to the "super" function from within it?
"foo".toUpperCase()
which method would get called? – EnosistoUpperCase
is already an extension method in Kotlin. – Enosis