reducing an Array of Float using scala.math.max

前端 未结 4 1871
温柔的废话
温柔的废话 2021-01-06 09:53

I am confused by the following behavior - why does reducing an Array of Int work using math.max, but an Array of Float requires a wrapped function? I have memories that this

4条回答
  •  情话喂你
    2021-01-06 10:09

    There is always scala.math.Ordering:

    Array(1f, 2f, 3f).reduceOption(Ordering.Float.max)
    

提交回复
热议问题