by distribot · 5y ago · 0 comments
https://majadhondt.wordpress.com/2012/05/16/googles-9-lines/
Is this example correct? Can someone explain to me how this: if (toIndex > arrayLen)
is correct?
If the array length is say 5, and toIndex is 5, that should still throw an index out of bounds exception, right? But it would be acceptable here.
Here is Dijkstra's opinion on why:
https://www.cs.utexas.edu/users/EWD/transcriptions/EWD08xx/E...
EDIT: as has been pointed out, the inequalities are correct. The original code can e.g. be found here, including doc comments showing the intended meaning of the arguments: http://www.groklaw.net/pdf3/OraGoogletrialexhibits/2012-04-2... (all the way at the end)