kotlin数据解构

fun main(arg: Array<String>) {
    val person = person("tom")
    var (name) = person//解构
    println(name)

//    -----------------
    val map = mutableMapOf<Int, String>()
    map.put(1, "tom")
    for ((key, value) in map) {//解构
        print("key =$key value = $value")
    }

}

data class person(var name: String)//数据类

 

posted on 2018-12-20 09:33  LoaderMan  阅读(557)  评论(0编辑  收藏  举报

导航