官术网_书友最值得收藏!

  • Perl 6 Deep Dive
  • Andrew Shitov
  • 146字
  • 2021-07-03 00:05:52

Num versus Numeric versus Real

As you saw in the diagram of the type hierarchy, some of the nodes are placed in ovals instead of rectangle boxes. Those are roles. Roles provide some interfaces to the classes that are inherited from them. We will talk about roles in more detail in Chapter 8, Object-Oriented Programming.

Some of the methods that the Numeric role provides us with are: Real, Int, Rat, Num, and Bool to convert the values to other data types; log, log10, exp, roots, abs, and sqrt for the corresponding mathematical calculations; and the pair prec and succ.

The Real role class gives us, among the rest, the following methods: rand, sign, round, floor, ceiling, and truncate.

If you want to dig deep and see all the connections between the classes, refer to the documentation pages listed at https://docs.perl6.org/type.html.

主站蜘蛛池模板: 孟村| 达拉特旗| 乡城县| 新安县| 陕西省| 绩溪县| 汉川市| 旬邑县| 石泉县| 普兰店市| 远安县| 社旗县| 隆化县| 吕梁市| 吴堡县| 麻江县| 玉溪市| 洪雅县| 塔城市| 拜城县| 阿拉善左旗| 郯城县| 苍溪县| 南乐县| 栾城县| 郎溪县| 邢台市| 凤城市| 武清区| 娄底市| 长海县| 桃源县| 清水县| 渝北区| 东源县| 绍兴市| 禄丰县| 乌鲁木齐市| 晋江市| 资阳市| 离岛区|