Closed zoujiaqing closed 5 years ago
bool hasKey(K, V)(V[K] arr, K key) {
auto v = key in arr;
return v !is null;
}
unittest {
string[int] arr;
arr[1001] = "1001";
arr[1002] = "1002";
assert(arr.hasKey(1001));
assert(!arr.hasKey(1003));
}
code: