On Tuesday, 8 August 2017 at 16:00:17 UTC, Steven Schveighoffer wrote:
I wouldn't use formattedRead, as I think this is going to allocate temporaries for a and b.

What would you suggest to use in its stead? My use-case is similar to the OP's in that I have a string of tokens that I want split into variables.


import std.stdio;
import std.format;

void main()
{
    string abc, def;
    int ghi, jkl;

    string s = "abc,123,def,456";
    s.formattedRead!"%s,%d,%s,%d"(abc, ghi, def, jkl);

    writeln(abc);
    writeln(def);
    writeln(ghi);
    writeln(jkl);
}

Reply via email to