在这个案例中您使用一个匿名内联函数,也称为一个闭包。
In this case, you used an anonymous inline function, also known as a closure.
对于这个函数,我们再次使用了一个简短的闭包注释。
For the function, we are once again using the shorthand closure notation.
第二个参数是一个函数闭包。
如果没有指定,函数将在定义它的闭包中运行。
A function will run in the closure that defines it unless otherwise specified.
我们也可以拥有直接返回闭包的函数,如清单6 所示。
We can also have functions that directly return closures, as we see in Listing 6.
方法或函数可通过传入参数与闭包通信。
A method or function can communicate with a closure by passing in arguments.
要了解闭包,首先需要了解匿名函数。
To understand closures, one first has to understand anonymous functions.
对函数使用断言通常很简单,而且最好使用闭包定义。
Predicate functions are often very simple and better off being defined using a closure.
因此出现了闭包并使lambda函数得到增强。
This is where closures step in and take the lambda functions to the next level.
它们还可以像普通函数一样内省到闭包中。
They can also introspect into a closure just like a normal function can.
它们还可以像普通函数一样内省到闭包中。
They can also introspect into a closure just like a normal function can.
应用推荐