Hot answers tagged

1

if you have code like: if(...) return true ..... else(...) return false this is an error, the compiler needs to know what value is to be returned, but if you have a condition if-else like the above, the compiler "can not know" a priori, what value will really return, your program linear search neither is correct, you should not look for the index ...


1

Compilers are dumb. They won't do exhaustive logic analysis of a function, but they will check to see if they think there's a path through the code that doesn't end with a return statement, assuming the function has a return type. That's almost certainly what's happened in your case. Here's an indepth explanation, but perhaps overly thorough. Maybe it will ...


Only top voted, non community-wiki answers of a minimum length are eligible