Ruby Math hypot()函数
Ruby中的 hypot() 函数在给出l和b作为参数时返回 sqrt(l^2 + b^2) 。它最终返回边长为 l 和 b 的直角三角形的斜边 。
语法 :Math.hypot(l, b)
参数 :该函数需要两个强制性参数 l 和 b,分别指定长度和底。
返回值 :该函数返回边为 l 和 b 的直角三角形的斜边 。
例子 1 :
输出:
例2 :
输出:
参考资料 : https://devdocs.io/ruby~2.5/math#method-c-hypot