Call different member functions on object sequence with a generic handler function?
Robert M. Münch
robert.muench at saphirion.com
Sun Jul 1 06:55:35 UTC 2018
On 2018-06-30 22:53:47 +0000, Jerry said:
> Btw this is pretty much std.algorithm.each
>
> import std.algorithm;
>
> void main() {
> auto cs = [ new C(), new C() ];
> cs.each!(o => o.A());
> }
>
> https://dlang.org/phobos/std_algorithm_iteration.html#.each
The looping needs to be done in the handler because there are two loops
running one after the other and the range to loop over is detected in
the handler too. Otherwise a lot of code duplication would happen.
--
Robert M. Münch
http://www.saphirion.com
smarter | better | faster
More information about the Digitalmars-d-learn
mailing list