fun chain2(s: String): String =
s.asSequence()
.map { it.uppercase() + it.lowercase() }
.filter { "a" in it }
.joinToString("-")
Function Call | Return Value | |||
---|---|---|---|---|
chain2("A BIKE") | → | |||
chain2("An Elephant") | → | |||
chain2("Garage") | → | |||
chain2("A monitor") | → | |||
chain2("Aardvark") | → |
Experiment with this code on Gitpod.io or as a Kotlin Playground