Sum string lengths

Andrey saasecondbox at yandex.ru
Wed May 13 13:52:13 UTC 2020


Hi,
I want to sum lengths of all strings in array:
> auto data = ["qwerty", "az", "!!!!"];

Fold and reduce doesn't work:
> auto result = data.fold!`a + b.length`(0U);

gives error:
> static assert:  "Incompatible function/seed/element: 
> binaryFun/uint/string"

How to do it in one line?


More information about the Digitalmars-d-learn mailing list