3 ms·
That description of closures is really odd to me and I know for a fact that it would not have worked on me as a child. After spending some time teaching program
by nv-vn 10y ago
That description of closures is really odd to me and I know for a fact that it would not have worked on me as a child. After spending some time teaching programming to middle schoolers/high school freshmen, I think they're really something that comes more naturally than that. The way scoping works for closures is almost instinctual in my experience, but the anonymous part is much harder to understand. Trying to write functions inside of functions is also fairly natural (although you might have to nudge the kids into that style of thinking), so you can teach closures with the use of named inner functions. I still haven't found a great way to teach lambdas that really sticks without them writing some code first and seeing how they can fit lambdas into there...