method chaining 方法链

来源:互联网 发布:iphone自动切换网络 编辑:程序博客网 时间:2024/06/06 00:05

Method chaining, also known as named parameter idiom, is a common syntax for invoking multiple method calls in object-oriented programming languages. Each method returns an object, allowing the calls to be chained together in a single statement.Chaining is syntactic sugar which eliminates the need for intermediate variables. A method chain is also known as a train wreck due to the increase in the number of methods that come one after another in the same line that occurs as more methods are chained togethe even though line breaks are often added between methods.

方法链接也称为命名参数法,是面向对象编程语言调用多个方法调用的常用语法。每个方法返回一个对象,允许所有的调用被一条语句链接起来。方法链也被称为“火车残骸”,因为在同一行中方法接踵而来导致更多的方法都被链接起来了,即使方法之间添加了换行符。




0 0
原创粉丝点击