kotlin的for循环

2025-01-14

基本使用

for (item in shoppingList){
    println(item)
    if (item == "RAM"){
        break
    }
}

获取index

for (index in 0 until shoppingList.size){
    println(index)
}