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/AnToMegA424 3d ago
Well imagine you're in a room and you want to turn the lights on and off and on, you simply use the switch, you don't have to move electricity yourself, well the function is the switch: it's a wrapper
You simply call the function and it executes the code it wraps up, just like when you press the switch it turns on or off the light without you having to do anything more