January 2019
Intermediate to advanced
512 pages
14h 5m
English
The term method cascading is not often found in the context of C++, and for a good reason—C++ does not really support it. Method cascading refers to calling a sequence of methods on the same object. For example, in Dart, where method cascading is supported explicitly, we can write the following:
var opt = Options();opt.SetA()..SetB();
This code first calls SetA() on the opt object, then calls SetB() on the same object. The equivalent code is this:
var opt = Options();opt.SetA()opt.SetB();
But wait, did we not just do the same with C++ and our options object? We did, but we skimmed over an important difference. In method chaining, the next method is applied to the result of the previous one. This is ...