正在加载图片...
Pattern Matching type Shape Square of side: double Rectangle of width: double length: double let getArea shape match shape with Square side-> side x side I Rectangle(width, length )-> width length let square= Square 2.0 printf"The area of the square is %f(getArea square)Pattern Matching type Shape = | Square of side: double | Rectangle of width: double * length: double let getArea shape = match shape with | Square side -> side * side | Rectangle (width, length) -> width * length let square = Square 2.0 printfn "The area of the square is %f" (getArea square)
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有