Description
Notice that https://github.com/exercism/problem-specifications/blob/master/exercises/binary-search/canonical-data.json uses -1
to indicate "searched-for item is not in the array". The question: Should this be considered an error? If so, binary-search
is covered by #1311 .
I consider searching for a nonexistent item an occurrence that the implementation should expect to routinely happen -- in a language with exceptions, for example, I would not recommend the use of an exception for this. A language with optionals would use its None
for this case, and use Some(index)
when there actually is an index.
However, I'll refrain from commenting on whether this should be represented in JSON as a -1
sentinel or an error
object or null
.
In the absence of any other preference, I would suggest to keep it as -1
, and close this issue without changes.