Kotlin ArrayList类型toTypedArray转换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 Point(x=0.0, y=0.0) 0 Point(x=0.1, y=0.1) 0 Point(x=0.5, y=0.5)
1 Point(x=0.6, y=0.6) 1 Point(x=1.0, y=1.0)
kotlin forEachIndexed arrayListOf<String>-CSDN博客文章浏览阅读129次。Python for循环中的zip_python zip函数用于for循环_zhangphil的博客-CSDN博客。https://blog.csdn.net/zhangphil/article/details/131003571
扁平的MutableList元素每隔若干元素一组装入新MutableList,Kotlin-CSDN博客文章浏览阅读1.1k次,点赞19次,收藏23次。给定长度值length,把列表切分成每段长度为length的N段列表,Kotlin_zhangphil的博客-CSDN博客。扁平的MutableList元素每隔若干元素一组装入新MutableList,Kotlin。文章浏览阅读652次。总长度:22 随机生成每段长度:4 算出段数:6。https://blog.csdn.net/zhangphil/article/details/134517311