[Issue 15038] New: Associative Array .get property const vs immutable

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Fri Sep 11 05:55:49 PDT 2015


https://issues.dlang.org/show_bug.cgi?id=15038

          Issue ID: 15038
           Summary: Associative Array .get property const vs immutable
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: luis at luismarques.eu

An associative array of string[string] can't be indexed with .get using a
const(char)[], unlike normal/raw indexing:

void main()
{
    string[string] foo = ["k": "v"];

    const(char)[] key = "k";
    string value;

    // if this works...
    assert(foo[key] == "v");

    // and this works...
    string* pValue = key in foo;
    value = pValue ? *pValue : null;
    assert(value == "v");

    // ...then this should work
    //assert(foo.get(key, null) == "v");
}

--


More information about the Digitalmars-d-bugs mailing list