I want to declare multiple global variables in Kotlin with names like vehicle1, vehicle2, vehicle3... using a loop.
I think this is how one would do it in C++ ->
for(i=0; i<10; i++){
int vehicle[1];
}
答案 0 :(得分:0)
So you want an Array with 10 Strings, each one having different names right? You can do something like this:
val vehicles = emptyArray<String>()
for (i in 0 until 10) vehicles[i] = "vehicle$i"