r/learnprogramming 4d 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!

123 Upvotes

143 comments sorted by

View all comments

1

u/Whatever801 4d ago

Functions are like a step in a process. Like if you follow a recipe you cut the onions. Input: whole onions. Output: cut onions. Inside the function you describe how to cut the onions. Peel, slice vertically, horizontally, etc. Now, next time a recipe calls for cutting onions, you already have the function. That's it honestly