Ok, context is required here.
try { int i = 0; while(true){ someArray[i]; i++; } } catch (IndexOutOfBoundsException ex) { //done }
try { int i = 0; while(true){ someArray[i]; i++; } } catch (IndexOutOfBoundsException ex) { //done }
(Yes, list.index exists. I know. Thank you.)
# pythonic pseudocode
def exists(x, C):
try:
C[x]
except:
# could be more specific
# IndexError, KeyError, etc...
return False
return True