Content deleted Content added
→Rationale: Add my opinion |
moved C++ iostream example from Method cascading to this article |
||
Line 33:
While chaining is syntax, it has semantic consequences, namely that requires methods to return an object, and if implementing cascading via chaining, this must be the current object. This prevents the return value from being used for some other purpose, such as returning an [[error value]].
==Examples==
A common example is [[iostream]] in [[C++]], where for example <code><<</code> returns the left object, allowing chaining.
Compare:
<source lang=cpp>
a << b << c;
</source>
equivalent to:
<source lang=cpp>
a << b;
a << c;
</source>
==See also==
|