tuple(...).each error; why does foreach work and std.algorithms.each doesn't ?
    wjoe 
    invalid at example.com
       
    Tue Feb 11 18:11:44 UTC 2020
    
    
  
Consider a function to format the parameters of a function call:
pure nothrow string fmtArgs(ARGS...)(ARGS args)
{
    string result;
    // 1)
    foreach(a; args) {
       result ~= a.to!string;
    }
    // 2)
    args.each!(a => result ~= a.to!string);
    return result;
}
In my mind, if something works with foreach, it should also work 
with std.algorithm.each.
However if I try something like 2) the compiler complains with 
error: cannot deduce function from argument types !()(uint, 
int)...
Technically I'd like to transform args into a range/array of 
strings but I'm not smart enough to understand the error messages 
these functions in std.algorithms produce.
How is 1) different from 2) ?
    
    
More information about the Digitalmars-d-learn
mailing list