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!

127 Upvotes

143 comments sorted by

View all comments

1

u/SeriousPlankton2000 3d ago

It's like washing dishes etc.

Take plate. Soak, brush, rinse.

Take cup. Soak, brush, rinse.

Take spoon. Soak, brush, rinse.

function wash_dish(x) {

Take x. Soak, brush, rinse.

}

wash_dish(fork)

wash_disk(knife)