You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
This is a wonderful library. I have problem with method overloads and i have seen how to correct it. In the image below, the result of the division on ComputeScoreInternal should be a float, if not there are duplicates in score. ComputeSum is working fine but the division after is coercing the value to int, so If i call the function MyFunc(1,1):
void MyFunc(int a, int b); => 0 Score void MyFunc(decimal a, decimal b => 0 Score Wrong
They are returning the same score.
Wrong:
Right:
The text was updated successfully, but these errors were encountered:
This seems unlikely, although I think your change is a good one. In your example, the "score" for converting an Int to a Decimal is 5. Converting two Int32 to Decimal would give a SUM of 10, and then divided by 2 is 5. The score on the second one would be 5, not 0.
For this to be an issue, there would either need to be a lot more parameters or the conversion would be much closer than int->decimal. An Int32 -> UInt32, for example, only returns 1, and if just one of the arguments was not a match, then you'd hit the integer rounding.
Did you actually have a test case where the wrong method was getting called?
Hi,
This is a wonderful library. I have problem with method overloads and i have seen how to correct it. In the image below, the result of the division on ComputeScoreInternal should be a float, if not there are duplicates in score. ComputeSum is working fine but the division after is coercing the value to int, so If i call the function MyFunc(1,1):
void MyFunc(int a, int b);
=> 0 Scorevoid MyFunc(decimal a, decimal b
=> 0 Score WrongThey are returning the same score.
Wrong:
Right:
The text was updated successfully, but these errors were encountered: