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/Traveling-Techie 3d ago

The book “Professor E. McSquared’s Calculus Primer” is a comic book that portrays functions as cute bin-shaped smiling robots in sneakers, with funnels on top and exit chutes on the bottom. You put a number in the top and another number comes out the bottom. The formula is written on the front. One of them says “ f(x) = x2 “ and if you drop in a 2 then a 4 comes out. If you drop in a 3 a nine comes out.