Return type polymorphism in C-like languages

后端 未结 5 617
梦如初夏
梦如初夏 2021-01-17 14:46

Why don\'t we see C-like languages that allow for callables with polymorphism in the return type? I could see how the additional type inference would be a hurdle, but we hav

5条回答
  •  一个人的身影
    2021-01-17 15:38

    double x = (double)foo();
    

    The above is ambiguous if there are versions of foo() that can return double, int, float, etc.

提交回复
热议问题