Created
August 7, 2019 03:08
-
-
Save saidihasan/d77bc73ab426f0ee3c0f8875550c9255 to your computer and use it in GitHub Desktop.
Kotlin Functional with accessing context inside the function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun main() { | |
// TODO 2 | |
val text = formatText("Kotlin is Awesome") | |
val lowerCase = text["lowerCase"] | |
val upperCase = text["upprintln"] | |
// TODO 3 | |
println(lowerCase) | |
println(upperCase) | |
} | |
// TODO 1 | |
fun formatText(text: String) = with(text){ | |
mapOf( | |
"lowerCase" to this.toLowerCase(), | |
"upperCase" to this.toUpperCase() | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment