re: Explain Lambda expressions like I'm five VIEW POST

FULL DISCUSSION
 

These five years olds are too smart, they can understand functional programming :-D

How would I explain it to a 5 year old who doesn't even know what programming is?

You have three toy buttons: bark, squeal, roar (the names + the functions). Every time you push one of them something magic happens (the function body) and you hear the corresponding sound (the function result). So every button has a function, a purpose.

Your little brother manages to erase the label "roar" from the third button so you decide to apply on it one of your Batman stickers.

You know that if you press the "Batman" button you're still going to hear a roar, no matter what the new name says.

Even if you remove the sticker and lend it to one of your friends, anytime they're going to press the button they're going to hear a roar.

code of conduct - report abuse