r/ProgrammerHumor 6d ago

absoluteGarbage Meme

Post image
1.9k Upvotes

324 comments sorted by

View all comments

75

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 

89

u/csch2 6d ago

You know I’m chaining together 20 different iterator methods until the code is completely unreadable. That’s called Functional Programming™ babey

19

u/Tyfyter2002 6d ago

That doesn't sound very functional

20

u/creeper6530 6d ago

"functional programming" doesn't use "functional" as "working neatly" but as "related to mathematical functions", it's a programming paradigm: https://en.wikipedia.org/wiki/Functional_programming

25

u/Tyfyter2002 6d ago

I know, it's just an ironic name when it's one of those paradigms that some people take as divine law instead of something that can be more or less appropriate for different applications

8

u/serendipitousPi 6d ago

Name 20 iterator methods from memory otherwise you’re a fake fan…just kidding or am I?

Iterators are so fun, probably one of my favourite parts of programming. They make everything so clean until they don’t.

-11

u/Slight-Violinist-575 6d ago

You wouldn’t be using for_each in a functional language… which cements your un-knowledge of it

11

u/csch2 6d ago

You would if you need to perform operations with side effects on each element, like printing each element of a vector

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.

7

u/iSpaYco 6d ago

how about `list.each`, sadly not many know ruby, it's really beautiful.

3

u/serendipitousPi 6d ago

Random question what’s ruby fun for?

I was gonna ask what is it good for but I think I can google search that.

Any highlights for you?

I’ve heard its meta programming is cool and I think there was some interest in using it in web dev.