Reputation: 15
What I'm currently doing:
var idList = mutableListOf<Int>()
fun main() {
for (number in 1000000..1999999) {
idList.add(number)
}
println(idList[0]) //testing purposes
println(idList[1]) //testing purposes
}
I feel like this is very inefficient. Is there a better way?
Upvotes: 1
Views: 552
Reputation: 3909
One option I can think of right now is like this
val numbers = (1000000..1999999).toMutableList()
println(numbers.first())
println(numbers.last())
Upvotes: 2