闭包的第二部分是闭合的作用域,我可以用另一个例子来很好地说明它。
The second part of the closure is the closed scope, which I can best illustrate with another example.
关于闭包的技艺的讨论很不错,但是更关注业务的人会更欣赏下面这个例子。
All this talk of closure cookery is well and good, but the more business-minded among you will better appreciate the next example.
清单9是Rubyon Rails中的一个简短例子,清单中的闭包用于为一个HTTP请求编写响应代码。
Listing 9, a quick example from Ruby on Rails, shows a closure that is used to code the response of an HTTP request.
在学习乘法例子时,curry过的闭包使得实现计算的函数模式出奇得容易。
As you learned with the multiplication examples, curried closures make it surprisingly easy to implement functional patterns of computation.
最后一个例子搜集名为ages的List中的所有元素,并将dec闭包(来自清单3)应用于这些元素。
The final example collects all the elements from the List referenced as ages and applies the dec closure (from Listing 3) to them.
Curry过的闭包可以用来模拟Visitor模式的基本元素,正如在Library例子中显示的。
Curried closures can be used to mimic the essential elements of the Visitor pattern, as we showed in the Library example.
为了阐述闭包的重要性,我们从一个没有闭包将无法解决的简单例子开始,然后再涉及一些更难的。
In order to demonstrate the importance of closures, we'll start with a simple case which can be solved without them, and then move on to something harder.
为了阐述闭包的重要性,我们从一个没有闭包将无法解决的简单例子开始,然后再涉及一些更难的。
In order to demonstrate the importance of closures, we'll start with a simple case which can be solved without them, and then move on to something harder.
应用推荐