Kotlin ArrayList tipo toTypedArray convertir Array

Kotlin ArrayList tipo toTypedArray convertir Array

 

data class Point(val x: Float, val y: Float)

fun array_test(points: ArrayList<Array<Point>>) {
    points.forEachIndexed { idx, ap ->
        ap.forEach {
            print("$idx $it ")
        }

        println()
    }
}

fun main(args: Array<String>) {
    val p1 = arrayListOf(
        Point(0.0f, 0.0f),
        Point(0.1f, 0.1f),
        Point(0.5f, 0.5f),
    )

    val p2 = arrayListOf(
        Point(0.6f, 0.6f),
        Point(1.0f, 1.0f),
    )

    array_test(arrayListOf(p1.toTypedArray(), p2.toTypedArray()))
}

 

0 Punto(x=0,0, y=0,0) 0 Punto(x=0,1, y=0,1) 0 Punto(x=0,5, y=0,5) 
1 Punto( x=0,6, y=0,6) 1 punto(x=1,0, y=1,0) 

 

 

 

kotlin forEachIndexed arrayListOf<String>-CSDN BlogEl artículo ha sido visto y leído 129 veces. La función zip_python zip en Python for loop se utiliza en el blog-CSDN de for loop_zhangphil. https://blog.csdn.net/zhangphil/article/details/131003571

El elemento plano MutableList se inserta en una nueva MutableList cada pocos elementos, blog de Kotlin-CSDNEl artículo ha sido visto y leído 1,1 mil veces, me ha gustado 19 veces y ha recopilado 23 veces. Dado un valor de longitud, divida la lista en listas de N segmentos, cada una de ellas de longitud, blog-CSDN de Kotlin_zhangphil. El elemento plano MutableList se empaqueta en una nueva MutableList cada pocos elementos, Kotlin. El artículo ha sido visto y leído 652 veces. Longitud total: 22 Longitud generada aleatoriamente de cada segmento: 4 Número calculado de segmentos: 6. https://blog.csdn.net/zhangphil/article/details/134517311

 

Supongo que te gusta

Origin blog.csdn.net/zhangphil/article/details/135034214
Recomendado
Clasificación