The Magic function

Report a typo

Write a magic function that works with a lambda with a receiver and performs any operation with a string.

Sample Input 1:

hello

Sample Output 1:

OLLE
Write a program in Kotlin
fun String.magic(init: String.() -> String): String {
// Write your code here
}

fun main() {
val str = readLine()!!
val res = str.magic {
uppercase().reversed().dropLast(1)
}
println(res)
}
___

Create a free account to access the full topic