kotlin 学习之路

 val array= arrayOf("1", "2")


    array.map {
        println(it)
    }  

打印
1
2

fun main(args: Array) {
    val person = Person("AAA")
    val person2 = Person("BBB")

    val arrayP = arrayOf(person, person2)
    arrayP.map {
        println(it.name)
    }
}

internal class Person(name: String) {
    var name = "小米";

    init {
        this.name = name
    }
}

打印

AAA
BBB

你可能感兴趣的:(kotlin 学习之路)