视频 视频老师的博客 更详细 1、 for 循环 //for item in elements elements可以是数组、集合 //1.1 for-in println("for-in") for(item in items){ print("$item ") } //1.2 forEach println("\nforEach") items.forEach{ print("$it ") } //1.3 forEachIndexed println("\nforEachIndexed") items.forEachIndexed{ index, item -> print("$index:$item ") }