I wrote a search function and expected Result := i to work like return in C. The body is for i := 0 to High(A) do if A[i] = V then Result := i; Result := -1; and it returns -1 for every input, even when the value is in the array. Older tutorials assign to the function's own name instead of Result.
How does a Pascal function actually return its value, what is the difference between the two styles, and how do I leave a function early with a value?




