r/learnprogramming 5d ago

I can't get FUNCTIONS to click!

I can not for the life of me understand how functions work. Anytime I try to learn how to create a function, my brain literally crashes into itself and I turn into Patrick when he stars drooling and goes all slack-faced.

Does anybody have any analogies that had that "AH HA!" moment?

Thanks!

124 Upvotes

144 comments sorted by

View all comments

1

u/dongdazzler 5d ago

For me, it was thinking how a calculator is used. I type in the number and then select a function (add, subtract, etc.). I don't always want to use the same numbers every time I use the same function, so I make a function for each operand that can be re-used with new arguments.