In the operator documentation, it says this:
x..y
- cascading member access. Results in x, which is useful for chaining together method calls.
What does this mean? How is this used? Searching for "cascading member access" only meaningfully served me back that excerpt from the Beef documentation.
When it says it "results in x", that means after any resolving any calls to y, which is consistent with how the null conditional operator (
?.
) works. What that means, is that instead of doing something like this:...you can use
String()..AppendF(...)
instead ofString().AppendF(...)
, and since that expression will resolve (again, after theAppendF
is called) to the left side of the operator, which is the same ass
, it can all be put into theWriteLine
call:And the "chaining" bit refers to use multiple cascading member operators in a row to sequentially call members on the same object in the same expression. For example, you can do this:
...instead of this: