Answer the question
In order to leave comments, you need to log in
Why are procedures (closures) needed in programming?
Why are procedures (closures) needed in programming?
Here is the ruby code.
1) - percent. function.
var = Proc.new do
puts 'Как-то так'
end
var.call => Как-то так
def var
puts 'Как-то так'
end
var = > Как-то так
Answer the question
In order to leave comments, you need to log in
You have misunderstood the question. By giving an example, you did not reveal the whole essence of closures. Namely, that they can be passed as parameters to other functions/methods. That. the method can be internally extended by an anonymous function.
But this approach should not be abused.
In any case, closures or ordinary procedures/methods are the same approach --- a description of the program in steps: what and how to do to get the result.
It is much more interesting to describe the problem in the form of boundary conditions and obtain a solution without describing the algorithm (see Prologue), but this approach is very limited and resource intensive.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question