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

  • 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.

主站蜘蛛池模板: 玛纳斯县| 乃东县| 林西县| 肃南| 曲靖市| 新昌县| 天镇县| 双峰县| 晋中市| 洞头县| 麟游县| 广平县| 南丹县| 襄汾县| 扶沟县| 贵德县| 邓州市| 苏尼特左旗| 宜君县| 唐海县| 通榆县| 南陵县| 汕尾市| 福海县| 酒泉市| 台湾省| 略阳县| 探索| 叶城县| 香格里拉县| 清苑县| 行唐县| 大竹县| 古浪县| 大姚县| 高青县| 林西县| 石河子市| 宣汉县| 仪征市| 黄龙县|