By default, they are passed by value, meaning that if we would update the value passed within the closure function definition, it would not update the outside value.
默认情况下,它们是由值传递的,意味着如果要更新传递到闭包函数定义内的值,则不更新外部值。
This closed scope is the communication that ties the closure to the calling function and the code that defines it.
这个闭合的作用域是将闭包同调用函数和定义它的代码联系起来的纽带。
In this case the returned function object is a closure which encapsulates some logging code and the data needed to call the original function.
这种情况下返回的函数对象就是一个闭包,其中封装了一些日志代码和最初的函数调用所需要的数据。
Curious readers will be wondering what makes a functor different from an anonymous function or closure.
好奇的读者会想是什么使仿函数不同于匿名函数或闭包呢?
When an inner function gains and USES access to its outer function's variables it is known as a closure.
当内部函数获得和使用其外部函数的变量时,就称其为一个闭包。
It ACTS like a macro in this context, where calling the method of function via the closure makes the function call in the context of where it's defined.
它在此上下文中用作宏,通过闭包调用函数方法将在定义它的上下文中执行函数调用。
A Groovy Closure is an anonymous function that can access its enclosing scope, can be called repeatedly at will, and be passed around as it were data.
一个Groovy闭包是一个匿名函数,它可访问包含它的范围,可随意被重复调用,并可将其当作数据到处传递。
Function literals and the related concept of a closure are discussed in the section called "Function literals and Closures" in Chapter 8, Functional Programming in Scala.
字面函数和闭包相关的概念会在《第8章-scala函数式编程》的“字面函数和闭包”章节中被讨论。
However, we can set up a closure at the beginning of the function to keep the string from having to be passed on each call.
不过,我们可以在函数的起始处设置一个闭包(closure),以使得不再必须为每一个调用都传递那个字符串。
Variables to be imported from the outside environment are specified in the use clause of the closure function definition.
从外部环境中导入的变量是在闭包函数定义的use子句中指定的。
To build a function that USES a closure, you simply use the yield keyword to invoke the closure.
要构建一个使用闭包的函数,只需要使用yield关键字来调用该闭包。
The closure of a peer socket can also be detected with the write API function.
同样,可以用writeapi函数来探测对等套接字的闭包。
For the error callback function, you pass a simple closure that simply displays the error information.
如果callback函数失败,就传递一个显示失败信息的终止参数。
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的函数对象)以及流作为日志输出。
Notice that once again, we used a shorthand closure for the predicate function passed to the filter function.
请再次注意,我们为传递给filter函数的断言函数使用了一个简短的闭包。
The only other important thing to note is the callback function, or, the closure created for the request's onreadystatechange function.
除此之外,惟一需要注意的是回调函数,或者为请求的onreadystatechange函数创建的闭包。
Though you can pass another closure to it, instead pass it a reference to another function called addEmployee.
尽管您可以传递另一个闭包给它,而不是将其作为一个引用传递给另一个名为addemployee的函数。
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是绑定了数据的函数。
As the above example illustrates, a closure is a function that is "closed over" specified variables.
正如上面例子说明的,closure是“closedover”特定变量的函数。
A closure "closes around" these references, so the function invocation can safely refer to the variables even when the variables have gone out of scope!
一个闭包封闭了这些引用,所以函数调用可以安全的引用这些变量,即使它们已经超出了函数的作用域。
A closure is a function that carries an implicit binding to all the variables referenced within it.
闭包是一个会对它内部引用的所有变量进行隐式绑定的函数。
A closure is a function that is evaluated in its own environment, which has one or more bound variables that can be accessed when the function is called.
闭包是在它自己的环境中执行计算的函数,它有一个或多个绑定变量可以在调用函数时访问。
How can I rewrite this so that Closure Compile renames my function?
我如何重写这个这样关闭编译重命名我的函数吗?
In Listing 8 you avoid the closure itself by adding another function, thereby preventing the leak.
清单8则通过添加另一个函数来避免闭包本身,进而阻止了泄漏。
The "closure" can be viewed as a temporary object that exists in the function scope.
“闭包”可以被看成是在function scope中的一个临时对象。
Unfortunately, it will result in the error message shown in Figure 5, because the function declared in the dojo.forEach method call creates a closure that defines this as referring to its own body.
不幸的是,它将导致图5所示的错误消息,因为在dojo. forEach方法调用中声明的函数创建了一个闭包,该闭包将this定义为引用它本身。
That is, a closure is an anonymous function that, when created, attaches to itself the value of variables from the scope of the code that created the function.
就是说,closure是个匿名函数,在其创建时,将来自创建该函数的代码范围内得变量值附加到它本身。
After ramp up, NPI project leader will submit project closure report for review with cross function department, then close whole NPI project after approval.
在爬坡量产后,项目团队领导人提交项目结束报告给各职能部门进行审核,在批准后正式关闭整个新产品导入项目。
The inclusion and equality relations and the closure properties under function composition operator among these classes are completely decided.
这些类之间的包含与相等关系以及在函数复合运算下的封闭性质被完全确定。
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.
当你使用闭包时,记得包含函数的调用对象,包括所有的函数参数和本地变量,会有跟闭包一样的存活时期。
应用推荐