in reply to Index or iterate - your choice
Generally speaking, if you want to provide a list of things, just return a list. People can assign it to an array and loop through it, access a particular element by index, etc.
The exceptions would be where there are so many list items or the items are so big, that they would use too much memory to store in an array, so accessing them one by one is better; or if generating each item is relatively expensive (in terms of time, CPU, network activity, etc) so if you can avoid fetching the entire list, that is preferable. In these cases use an iterator instead.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Index or iterate - your choice
by thomas895 (Deacon) on Jan 27, 2021 at 21:12 UTC | |
by tobyink (Canon) on Jan 27, 2021 at 23:17 UTC | |
|
Re^2: Index or iterate - your choice
by GrandFather (Saint) on Jan 27, 2021 at 21:19 UTC |