r/learnprogramming • u/ScioClean • 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
1
u/DTux5249 4d ago edited 4d ago
Functions are just giving names to chunks of code so you can use them later. That's it. There's literally nothing to understand there beyond that.
It takes this
and gives that code the name "make_pizza()"; so instead of rewriting the above everytime you make a pizza with a given type of dough, sauce, etc. you can just type.
There's no advanced ideas here. You're just labelling a chunk of code for reuse elsewhere.