Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can someone define what a closure is in real world language? [duplicate]

Tags:

closures

Possible Duplicate:
What is a ‘Closure’?

I read more and more about closures but I don't really get what it is from a practical standpoint. I read the wikipedia page on it but it doesn't really clear anything up for me because I have more of a practical background in programming (self taught) as opposed to a computer science background. If this is a reundant question, I apologize as my initial search didn't yield anything that really answered it for me.

edit: Thanks for pointing me in the right direction! I see this has already been clearly answered before so I will close the question out.

like image 725
MattC Avatar asked Jan 23 '23 11:01

MattC


2 Answers

Eric Lippert's blog does a pretty good job at explaining this in a practical sense.

And so does Kyle at SO

like image 155
Sev Avatar answered Jan 30 '23 08:01

Sev


An operation is said to be closed over a set when the result of that operation also belongs to that set.

For example - Consider a set of positive integers. Addition is a closed operation over this set because adding two positive integers would always give a positive integer.

However subtraction is not closed over this set because 2 - 3 would give -1 which does not belong to the set of positive integers.

cheers

like image 42
Arnkrishn Avatar answered Jan 30 '23 06:01

Arnkrishn