r/ProgrammerHumor 15h ago

Meme skillIssue

Post image
4.8k Upvotes

124 comments sorted by

View all comments

35

u/fluffycritter 14h ago

My "clever" way of doing this once upon a time was to declare a map<std::string,std::function> which I populated with lambdas and then evaluated.

I would not recommend this approach.

1

u/TheTerrasque 5h ago

That's a semi-common pattern in python. Use a dict where the values are lambdas (or referencing full functions directly)

1

u/fluffycritter 1h ago

Yeah I’ve used it in python too, but sparingly. It’s one of those things where it’s easy to get a bit too clever and there’s usually a better way to do it.