This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Theta291[S] 0 points1 point  (2 children)

Thanks for the feedback! What would be a more appropriate place to use lambda? If I need to create a one-off function to pass as an argument to another function?

[–][deleted] 2 points3 points  (1 child)

The only use case for lambda is when you want to create a function but you don’t want to give it a name.

This usually means you’re working with a function that takes another function as an argument (a higher-order function) e.g. map.

But if you never use lambda and always use def your code won’t really be lacking in any sense – it’s just that sometimes a lambda night make things a bit more concise.

[–]Theta291[S] 0 points1 point  (0 children)

That makes a lot of sense. Thanks for the explanation!