Consider the following:
int combine(int a, int b) { return a + b; } float combine(int a, int b) { return a - b; }
If I had to call the combination (1, 2), the compiler could not find out which of the two methods I want to call (this is ambiguous).
You can almost do an example of checking return types, but what about:
var c = combine(1, 2); dynamic d = combine(1, 2); combine(1, 2);
In the above, what should be the value of c or d? 3? -one? This is impossible to say. What about the last statement where no value is assigned? I did not define the overload that void returns, and which of the two methods should it call?
Fayth
source share