Skip to content

Instantly share code, notes, and snippets.

@saidihasan
Created August 7, 2019 03:08
Show Gist options
  • Save saidihasan/d77bc73ab426f0ee3c0f8875550c9255 to your computer and use it in GitHub Desktop.
Save saidihasan/d77bc73ab426f0ee3c0f8875550c9255 to your computer and use it in GitHub Desktop.
Kotlin Functional with accessing context inside the function
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