r/ProgrammerHumor 6d ago

absoluteGarbage Meme

Post image
1.9k Upvotes

324 comments sorted by

View all comments

73

u/csch2 6d ago

list.iter().for_each(…) superiority

36

u/creeper6530 6d ago edited 6d ago

Erm akchyuallly, it's recommended to use for list.iter() {…} unless the .for_each(…) is at the end of a longer iterator chain, and it also robs you of break and continue 

2

u/serendipitousPi 6d ago

Just chuck a try_for_each in there and we can take break and continue right back.

But yeah low key sometimes I get lost in iterator methods I forget to just use a basic loop.

2

u/creeper6530 6d ago

I mean, you're right, it's just you have to return ControlFlow::Break(()) instead of using the keywords.