加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

是否有一个perl6对应的powershells get-member来“分析”一个变

发布时间:2020-12-16 06:23:42 所属栏目:大数据 来源:网络整理
导读:题: 是否/ Power shells get-member的Perl6对应物是什么来“分析”变量的属性? 说明: 在Perl 6中,您可以获得变量的属性/属性,例如: my $num=16.03;say $num.numerator; # output: 1603say $num.denominator; # output: 100say $num.nude; # output: (160
题:
是否/ Power shells get-member的Perl6对应物是什么来“分析”变量的属性?

说明:
在Perl 6中,您可以获得变量的属性/属性,例如:

my $num=16.03;
say $num.numerator;   # output: 1603
say $num.denominator; # output: 100
say $num.nude;        # output: (1603 100)
say $num.WHAT;        # output: (Rat)

如何找出变量具有哪些属性/属性(分子等)和方法/函数(WHAT)?
在Powershell中,我将变量传递给get-member,如:
$num | get-member将显示所有属性和功能.

解决方法

最好的方法是咨询任何类型的文档.WHAT告诉你,例如鼠标 https://docs.perl6.org/type/Rat.

如果必须以编程方式使用它,则可以使用.^方法向对象询问其方法.

> my $num = 16.03
16.03
> $num.^methods
(Rat FatRat Range atanh Bridge sign sqrt asech sin tan atan2 acosech truncate
asinh narrow base floor abs conj acosh pred new asec cosec acotan cosh ceiling
nude acos acosec sech unpolar log exp roots cotan norm sinh tanh acotanh Int
Num Real sec asin rand polymod log10 cos round REDUCE-ME succ base-repeating
cis cosech isNaN Complex cotanh atan perl WHICH Str ACCEPTS gist Bool Numeric
DUMP numerator denominator)

你可以用.^属性类似地看到属性(‘属性’),但是你应该访问的任何东西都会有访问器方法,所以你不应该真的需要这样做.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读