2 ms·
Ruby has had lazy iteration[1] for quite a while but as n here is only 10 there's really not much to loose in not using it. In fact given that only a subset of
by Lio 4y ago
Ruby has had lazy iteration[1] for quite a while but as n here is only 10 there's really not much to loose in not using it.
In fact given that only a subset of users will be admin users for the second loop n is going to < 10 anyway.
I believe it was Rob Pike that actually said something along the lines of not bothering to optimise until you know that n is large[2].
1. https://ruby-doc.org/core-2.5.0/Enumerator/Lazy.html https://ruby-doc.org/core-2.5.0/Enumerator/Lazy.html
2. https://users.ece.utexas.edu/~adnan/pike.html https://users.ece.utexas.edu/~adnan/pike.html