An approach that assumes that only two values ββare added to a sequence,
Seq(rect.getWidth, rect.getHeight).sorted.reverse.foldRight(1.0)( _ / _ )
The code you offer is more readable, although less error prone, with most divisions by zero, a little attention will be required.
source
share