Operator Return - Example

We have a method in the example below, which compares two numbers and returns a result respectively -1, 0 or 1 depending on if the first argument is smaller, equal or larger than the second argument, given to the function. The method uses the keyword return in three different places, in order to return three different values according to the logic of comparing the numbers:

results matching ""

    No results matching ""