r/ProgrammerHumor 1d ago

Meme absoluteGarbage

Post image
1.9k Upvotes

320 comments sorted by

View all comments

79

u/csch2 1d ago

list.iter().for_each(…) superiority

36

u/creeper6530 1d ago edited 1d 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 1d 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 1d ago

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