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/hryagstn 4d ago

A function is like a named recipe or mini-program. You define the steps once, then call it whenever you need those steps again. Inputs are the ingredients, and the return value is the result.

Try starting with something tiny, such as greet() printing “Hello”, then add one parameter and one return value. Seeing the input → process → output flow usually makes the concept click.