5 ms·
And if indexOf returned null or undefined when the value is not found, this could not even be expressed with an ordering relation.
by pwdisswordfish 10y ago
And if indexOf returned null or undefined when the value is not found, this could not even be expressed with an ordering relation.
- junke 10y agoWhich is ... great? what is your point?
- pwdisswordfish 10y agoThat whether an element was found in a list or not has nothing to do with the order relation on the type of indices. Conceptually, it's a completely distinct case; in a more solid type system it would be captured by an option type. This becomes especially evident when you attempt to generalise this searching operation to arbitrary maps.