u/arocniesin r/Kotlin • Recommends
On “Which one is faster, forEach() or the good old for loops?”
[video
Speed does matter! Just don't prematurely optimize.
Sure you can save 13.6 milliseconds of loading time because you chose one loop over another... Good stuff, you only spent a whole hour of dev time for those gains. Instead, you could've made batch requests in your app's networking and saved 10 seconds and only spent an hour of dev time.
I get it though. Worrying about Big-O on a loop over three elements is something you do right out of college.
Remember, we write code for humans, not for computers!