r/learnprogramming • • Apr 05 '22

Name one programming/comp sci concept you never understood and if you understand it, try to explain it to them

Name a programming concept such as virtual functions, pointers, certain algorithms, etc that you always had a hard time understanding and why.

Someone else who reads yours and does understand it, try to explain it to them to help them learn

1.6k Upvotes

738 comments sorted by

View all comments

2

u/GoodTimesFastFingers Apr 05 '22

Curried functions. I've read definitions before and the code made sense but I don't understand why you would ever need one, and I could not tell you what a curried function is if I had to.

1

u/Ybl0k13 Apr 15 '22

In React I use curried in onclick callbacks

const handleClick = (index) => (event) => console.log({ index, event });

<li onClick={handleClick(1)}>

Helps when mapping out list items. Feels More intuitive to me.

1

u/GoodTimesFastFingers Apr 15 '22

Ooooooh! So I guess a curried function is a function factory? Funny enough I use that pattern all the time on React too :)