jQuery使用这种模式.本质上,它涉及每个方法返回对调用该方法的同一对象的引用.
myClassInstance
.DoMethodA()
.DoMethodB()
.DoMethodC()
.CleanUp();
Run Code Online (Sandbox Code Playgroud)
这个设计模式叫什么?
更新 接受的答案是正确的,这里是维基百科条目的链接 - 比答案中提供的链接信息量少:P http://en.wikipedia.org/wiki/Method_chaining