3 ms·
That is why I put the word "general"; C could be a dict, etc. I know that there are better ways for specific types, but the following code is a snippet that wor
by ggrrhh_ta 5y ago
That is why I put the word "general"; C could be a dict, etc. I know that there are better ways for specific types, but the following code is a snippet that works for fast prototyping and I have found it to be idiomatic in VB for collections (but I do very occasional VB, less than once a year).
# pythonic pseudocode
def exists(x, C):
try:
C[x]
except:
# could be more specific
# IndexError, KeyError, etc...
return False
return True