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?

I use the in operator:

if(key in aa) {
  there
}

if(key !in aa) { not there}


You can also fetch the pointer right there too:

if(auto pvalue = key in aa) {
  auto value = *pvalue;
  // go ahead and use it
}

Reply via email to