大多数GWT书籍和在线教程中的回调示例是用匿名内部类实现的。
Callback examples in most GWT books and online tutorials are implemented as anonymous inner classes.
不再有丑陋的匿名内部类:只要通过这些便捷方法使用闭包就可以!
No more ugly anonymous inner classes: just use closures through those shortcut methods!
但匿名内部类只是宽泛地近似于闭包,它们并没有深入到您需要的程度。
But anonymous inner classes give you only a loose approximation of closures, and they don't go as far as you need to go.
在类似匿名内部类的机制中使用代码块的一个优势是其简洁性。
One of the advantages of using code blocks over a similar mechanism like anonymous inner classes lies in its conciseness.
事实上,一个匿名内部类甚至不能同时扩展一个类和实现一个借口。
In fact, an anonymous inner class can't even extend a class and implement an interface at the same time.
Groovy则消除了这种限制,在Groovy中,匿名内部类可以修改外部的变量值。
This restriction is lifted in Groovy; you can change the values of variables in a containing scope from within an anonymous inner class.
我以前可能提到过,您将经常看到定义为匿名内部类的asynccallback类。
As I probably mentioned before, you'll frequently see AsyncCallback classes defined as anonymous inner classes.
第一组闭合括弧划定一个匿名内部类的构造,第二组划定匿名内部类的实例初始化语句块。
The first set of enclosing braces delineates the construction of an anonymous inner class, and the second set delineates the instance initializer for the anonymous inner class.
这里,ActionListener实现是适时定义的,它定义为一个匿名内部类,并直接附加到按钮上。
Here, the ActionListener implementation is defined in place, as an anonymous inner class, and directly attached to the button.
惟一需要以这种方式使用一个类的是一个默认构造函数(它允许您创建继承自类的一个匿名内部类)。
The only thing a class needs to be used this way is a default constructor (which allows you to create an anonymous inner class instance inheriting from your class).
addOrderFrom()方法成为公共类的匿名内部类创建的定义,将这两个工作项目包装起来。
The addOrderFrom() method collapses to the definition of an anonymous inner class creation of the command class, wrapping the two work items.
相比于每个匿名内部类都要对应一个类的做法来说,这种方式是个极大的改进,同时也使得代码的可读性更好。
This is an improvement over having to write a class any time an anonymous inner class is needed and can help keep the code more self-documenting.
考虑到包装这个方法的匿名内部类的真正用途,我留下了几行难看的样板代码—addorderfrom方法体中的两行代码。
I'm left with some ugly boilerplate code because of the anonymous inner class wrapping this method's real purpose - the two lines of code that appear in the body of the addOrderFrom method.
可以使用匿名的内部类来实现闭包。
Primarily, you can use anonymous inner classes to implement closures.
如果这个匿名类可被作为一个内部类单独放置,那么清单1中的代码将会简洁很多。
The code in Listing 1 would be much neater if the anonymous class was placed separately as an inner class.
如果这个匿名类可被作为一个内部类单独放置,那么清单1中的代码将会简洁很多。
The code in Listing 1 would be much neater if the anonymous class was placed separately as an inner class.
应用推荐