Why the former does not necessarily have a return value??
Where is the difference?
The reason is why
'don't know too much hope new bosses can be patient answer thank you ~ ~ ~
CodePudding user response:
Didn't quite understand the meaning of the original poster, but simply said it,Obviously the first piece of code is problematic (at the very least that break should not be placed behind the return),
Function to find the one match the parameters cardId and returns,
Definitely need to make one by one to compare the elements of an array, if not match, then the next to compare, until we find a matching element or not (just return 1) in the array,
But the first piece of code can only compare the first element, can't let all array elements,
Because when the first element, execute to the if statement, will return, also is to function as a result, both clauses (if - else returned)
Also no longer is the second, the third element,,,,
Correct processing logic should be the second code, then, if found, it returns the corresponding index, the current element does not match, will replace an element that directly compare the whole array, haven't find a matching element, explains that have nothing to find in the array, then return 1, said didn't find,
CodePudding user response:
The return value is positive, if you are first in the array is not qualified, then return 1, directly behind even with the same ID number no more, because the returnCodePudding user response:
The former is some, after entering cycle, every road has a return value, not to say that must be in the final return is the return value, as long as the return to it on every roadCodePudding user response:
If the former into the loop, there would be no return value, naturalCodePudding user response:
As long as not into the outer loop, there is no return valueCodePudding user response:
If g_gard_count 0, hum