You can also create an array directly: `Array((201...
# getting-started
j
You can also create an array directly:
Array((2018 - 1960 + 1), { i -> (i + 1960).toString() })
d
A lot less clear, imho.
e
But the performance is a little bit better
d
Do I smell premature optimization? 😄
j
I would not write it like this, but only wanted to show that direct creation is also possible
I guess I would end up with something like this:
Copy code
val numberOfYearsInRange = endYear - startYear + 1
Array(numberOfYearsInRange) { i -> (startYear + i).toString() }
👍 1
e
This is more readable