I need to init and push some values into a array something like:

//DMD64 D Compiler 2.072.2
import std.stdio;
import std.array;

void main()
{
    bool a = true;
    bool b = false;
    bool c = false;

    bool[] boolList;
    auto boolListAppender = boolList.appender();
    boolListAppender ~= [ a, b, c];
}

Live example : http://rextester.com/TJLIXU71426

My question is about

    bool[] boolList;
    auto boolListAppender = boolList.appender();
    boolListAppender ~= [ a, b, c];


I could do the same in one line with C++:

bool boolList[] = { a, b, c };

D alternative(at least my D alternative) seem long. Is there any better way for
initialing  and pushing values at the same time.

Erdem

Reply via email to