Quantcast
Channel: Questions in topic: "error"
Viewing all articles
Browse latest Browse all 7934

error "not all code paths return a value" in a function

$
0
0
Sorry, because I know this has been asked a hundred times before. But I have no idea why this code is giving me this error, because I cant see any path it could take for it to not return a value... Vector3 roadSnapping (Vector3 point){ //goes through every road in the array, checks if snapping to end point for (int i = 0; i < controlPoints.GetLength (0); i++) { if (Vector3.Distance (controlPoints [i, 0], point) < 10) { return controlPoints [i, 0]; } else { return point; } } } The "for" loop is unavoidable, it will always go through this, unless the length is less than 1, however if I put a "return point;" after the loop, I get an error message calling it unreachable code. thanks for any help u can give :)

Viewing all articles
Browse latest Browse all 7934

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>