On Friday, 13 September 2013 at 14:03:48 UTC, Gary Willoughby wrote:
What is the preferred method for testing the existence of a key in an associative array?

Well, I usually do it as:

int[string] someCache;

int getValue(string key)
{
    if (auto val = key in someCache)
        return *val;
    return someCache[key] = -3;
}

Reply via email to