I did try this but i get to Error's.
fun main() { val addExclamationMark: (String) -> String = {if it.contains("!") -> it else -> it + "!"} println(addExclamationMark("Hallo Welt")) } Type mismatch: inferred type is Unit but String was expected Expecting a condition in parentheses '(...)' Unexpected tokens (use ';' to separate expressions on the same line)
Can you please tell me how to do this right with some explanation so i understand Kotlin more ? ;)