v79
06/02/2024, 5:13 PMfirstOrNull
and a function that could return a nullable string. It's always returning an empty string when I'd rather it return a null:
private fun KSAnnotation.getArgumentValue(name: String): String? {
// I want to return null if the argument is not found, otherwise return the value as a string
return this.arguments.firstOrNull { it.name?.asString() == name }?.value?.toString() ?: null
}
Intellij tells me that the ?: null
is useless. But I really would like to return null and not an empty string.Tolriq
06/02/2024, 5:21 PMv79
06/02/2024, 5:33 PMWout Werkman
06/02/2024, 6:49 PM.ifEmpty { null }