The partial application of a closure is another closure object in which some values have been fixed.
闭包的部分应用程序是另一个Closure对象,在这个对象中有些值已经被修正。
In this case the returned function object is a closure which encapsulates some logging code and the data needed to call the original function.
这种情况下返回的函数对象就是一个闭包,其中封装了一些日志代码和最初的函数调用所需要的数据。
When a closure "captures" a variable it "lifts" the variable out of its local scope and effectively moves it into an anonymous object.
当一个闭包“捕获”一个变量时,它就会将这个变量提取出它的本地范围,移到一个匿名对象里。
We also grab the color and name of the dog, passed in the constructor and stored in the object, within the closure.
我们还在闭包内获取狗的颜色和名字,传递到构造函数中并存储到对象中。
By not having to import the object into the closure, we can save quite a bit of memory, especially if we have many closures that don't need this feature.
由于无需将对象导入闭包中,因此可以节省大量内存,尤其是在拥有许多不需要此功能的闭包时。
The big difference is that we don't use any properties of the object within the closure, since it is defined as static.
最大的差别是在闭包内不使用对象的任何属性,因为它被定义为静态类。
To create child nodes, I create a closure and declare a new object dubbed name, which takes parameters in the form of a map.
要创建子节点,我创建一个闭包并声明一个名叫name的新对象它接收map形式的参数。
The closure captures the information about the actual Web service method stub to be invoked (the function object called obj) as well as the stream for the log output.
闭包捕获真正被调用的Web服务方法存根(称为obj的函数对象)以及流作为日志输出。
The element is a sibling of, so I jump out of the closure, declare a friends object and, of course, attach a closure that contains a collection of friend elements, as shown in Listing 2.
元素是的兄弟元素,于是我跳出这个闭包,声明了一个friends对象,当然,还附加了一个集合了多个friend元素的闭包,如清单2所示。
The "closure" can be viewed as a temporary object that exists in the function scope.
“闭包”可以被看成是在function scope中的一个临时对象。
Calling the object reference shown in Listing 9 as a variable automatically calls the __invoke magic method, making the class itself act as a closure.
将清单9中所示的对象引用调用为变量将自动调用__invoke魔术方法,使类本身用作闭包。
Consider the example in Listing 1, where a closure is defined in a class, and then invoked after the object variable goes out of scope.
考虑清单1中的示例,其中closure定义为类,并且在对象超出范围之外后进行调用。
Resolution and closure, then, is mature object choice and in a certain sense there, too, it's a push forward, but we don't quite know toward what.
决心和结果才是,成熟的选择,它带着生命向前进,但我们不知道会去哪。
Notice how the mail object defined in the catch block takes a closure that defines the from, to, and message attributes.
注意catch块中定义的mail对象如何接受定义了from、to和message属性的闭包。
Here's another way to look at it: If an object is data with methods that operate on that data, then a closure is a function with data bound to that function.
从另一个角度来看:如果object是带有在其上运行的方法的数据,那么closure是绑定了数据的函数。
When you use a closure, remember that the call object of the enclosing function, including all function arguments and local variables, will last as long as the closure does.
当你使用闭包时,记得包含函数的调用对象,包括所有的函数参数和本地变量,会有跟闭包一样的存活时期。
But it has a performance impact since closure is created each time your object is created.
但它有一个性能的影响由于关闭了你的每次创建对象。
Lastly, the closure structure more closely follows the Law of Demeter since your object would, theoretically, be "reaching through" via the prototype chain.
最后,闭合结构更接近于得墨忒耳法自你的对象,从理论上讲,是“通过”通过原型链。
Lastly, the closure structure more closely follows the Law of Demeter since your object would, theoretically, be "reaching through" via the prototype chain.
最后,闭合结构更接近于得墨忒耳法自你的对象,从理论上讲,是“通过”通过原型链。
应用推荐