Skip to content

Instantly share code, notes, and snippets.

@Fitranugraha
Last active April 7, 2020 23:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Fitranugraha/04516402feb88daaf6aed6fd4236f06e to your computer and use it in GitHub Desktop.
Save Fitranugraha/04516402feb88daaf6aed6fd4236f06e to your computer and use it in GitHub Desktop.
Kotlin Syntax Should Remember
fun main(){
val allBooks = setOf("Macbeth", "Romeo and Juliet", "Hamlet", "A Midsummer Night's Dream")
val library = mapOf("Shakespeare" to allBooks)
println(library.any { it.value.contains("Hamlet") })
val moreBooks = mutableMapOf<String, String>("Wilhelm Tell" to "Schiller")
moreBooks.getOrPut("Jungle Book") { "Kipling" }
moreBooks.getOrPut("Hamlet") { "Shakespeare" }
println(moreBooks)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment