Function overloading by return type?

前端 未结 14 2245
终归单人心
终归单人心 2020-11-22 03:55

Why don\'t more mainstream statically typed languages support function/method overloading by return type? I can\'t think of any that do. It seems no less useful or reasona

14条回答
  •  无人及你
    2020-11-22 04:30

    For the record, Octave allows different outcome according to return element being scalar vs array.

    x = min ([1, 3, 0, 2, 0])
       ⇒  x = 0
    
    [x, ix] = min ([1, 3, 0, 2, 0])
       ⇒  x = 0
          ix = 3 (item index)
    

    Cf also Singular Value Decomposition.

提交回复
热议问题