与JAVA的不同,flex里面的Bound methods.
Bound methods 定义如下:
A bound method, sometimes called a method closure, is simply a method that is extracted from its instance.
和 Function Closure 的不同:
The key difference, however, between a bound method and a function closure is that the this reference for a bound method remains linked, or bound, to the instance that implements the method.
In other words, the this reference in a bound method always points to the original object that implemented the method. For function closures, the this reference is generic, which means that it points to whatever object the function is associated with at the time it is invoked。
调用的是bound method 时,那么该method 中的this 引用的是实现该方法的对象,并用该方法能够使用实现该方法的对象内的属性。。这一点和As2.0不同。
class ThisTest
{
private var num:Number = 3;
function foo():void // bound method defined
{
trace("foo's this: " + this);
trace("num: " + num);
}
function bar():Function
{
return foo; // bound method returned
}
}
var myTest:ThisTest = new ThisTest();
var myFunc:Function = myTest.bar();
trace(this); // output: [object global]
myFunc();
/* output:
foo's this: [object ThisTest]
output: num: 3 */
此代码中的全局this 和 Bound Function 里的this 引用的对象是不同的。
分享到:
相关推荐
However simple transformation methods exist to convert a bound constrained problem into an unconstrained problem. Fminsearchbnd与fminsearch的使用方法非常相近,除了对变量的边界进行约束。 ...
Vue.js 是一款流行的前端...需要注意的是,这个实现依赖于 QQ 输入法的接口,因此可能会受到其稳定性和可用性的影响。此外,为了提供更好的用户体验,还可以添加错误处理、识别结果的显示以及手写区域的优化等功能。
在Python中,类的方法有两种主要类型:绑定方法(Bound Methods)和非绑定方法(Unbound Methods)。本文将深入探讨绑定方法的概念及其应用。 1. **绑定方法** 绑定方法是Python中类的方法默认形式,它与对象紧密...
注意:您将需要访问数据库的权限,在security.cnf 中替换您的用户名和密码。 ** 方法 实例 我们认为克隆大小是独特突变序列的数量和在不同测序文库中发现的相同独特序列的所有不同实例的总和。 我们将这种混合克隆...
MATLAB通常会使用内置的分支和剪枝算法(Branch and Bound)或者基于线性规划的内点法(Interior-Point Methods)来求解MILP问题。 在实际应用`intprog`时,我们需要注意以下几点: 1. 问题规模:对于大规模问题,...
这种类型的绑定方法通常称为静态方法(static methods)或类方法(class methods)。 ##### 静态方法 静态方法是在类中定义的普通函数,它们不是绑定方法,也不需要`self`参数。它们主要用于执行与类相关的但并不依赖...
在此基础上,本文提出了两种近似分析方法:RBF(Reduction-Based Framework)和IBF(Incremental-Bound Framework),这两种方法都具有伪多项式的复杂度,相较于精确分析方法的指数级复杂度,它们能够在保证一定精度...
static methods的形 式呈現,例如 sort() , max(), min(), copy(), fill()。圖 5是兩個運用實例,其 語法和 C++完全相同:使用 generic algorithms時並不需要以角括號( )為「參 數化型別」做任何具體指定。這...