diff options
| -rw-r--r-- | kotlin.html.markdown | 11 | 
1 files changed, 11 insertions, 0 deletions
| diff --git a/kotlin.html.markdown b/kotlin.html.markdown index fe2811c5..d29b1471 100644 --- a/kotlin.html.markdown +++ b/kotlin.html.markdown @@ -175,6 +175,17 @@ fun helloWorld(val name : String) {      // Objects can be destructured into multiple variables.      val (a, b, c) = fooCopy      println("$a $b $c") // => 1 100 4 +     +    // destructuring in "for" loop +    for ((a, b, c) in listOf(fooData)) { +        println("$a $b $c") // => 1 100 4 +    } +     +    val mapData = mapOf("a" to 1, "b" to 2) +    // Map.Entry is destructurable as well +    for ((key, value) in mapData) { +        println("$key -> $value") +    }      // The "with" function is similar to the JavaScript "with" statement.      data class MutableDataClassExample (var x: Int, var y: Int, var z: Int) | 
