Call different member functions on object sequence with a generic handler function?
Basile B.
b2.temp at gmx.com
Sun Jul 1 07:13:27 UTC 2018
On Sunday, 1 July 2018 at 06:55:35 UTC, Robert M. Münch wrote:
> 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
Look at my solution then:
https://forum.dlang.org/post/kmkckipiwlvwahifelnc@forum.dlang.org
> and the range to loop over is detected in the handler too.
> Otherwise a lot of code duplication would happen.
More information about the Digitalmars-d-learn
mailing list