On Thursday, 2 April 2015 at 04:32:26 UTC, Martin Nowak wrote:
On Thursday, 2 April 2015 at 04:11:02 UTC, weaselcat wrote:
was it a conscious decision to make the AA [] operator not work like map/etc in C++?

What do you mean?

accessing a non-existing element in C++'s map/unordered_map inserts the default instead of raising an exception

int main(int argc, char *argv[])
{
    std::unordered_map<std::string, int> test;
    std::cout << test["hello"] << std::endl;
    return 0;
}

prints 0

void main()
{
    int[string] test;
    writeln(test["hello"]);
}

core.exception.RangeError@source/main.d(9): Range violation

Reply via email to