is there a more kotlin idiomatic way of doing this...
# announcements
w
is there a more kotlin idiomatic way of doing this?
Copy code
for (i in 0..fooCount) {
            foos.add(bar.getFoo(i))
        }
j
That is fine. If you're golfing code, you can do things like
val foos = (0..fooCount).map(bar::getFoo)
w
ok thanks, sometimes i'm not completely sure whether to cross the line and do things like that vs keeping it simpler
k
fooCount must be coming from somewhere ...
Copy code
collectionWhereFooCountCameFrom.forEach {         foos.add(collectionElement)
}
w
@Krotick its not iterable so i can't do that
k
it makes total sense then!