是否有 powershell get-member 的 perl 6 对应 "analyze" 变量(-object)?

Is there a perl6 counterpart of powershells get-member to "analyze" a variable(-object)?

问题: there/What 是 Powershells get-member 到 "analyse" 变量属性的 Perl6 对应物吗?

解释: 在 Perl 6 中你可以获得变量的 properties/attributes,例如:

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) 

我如何找出一个变量有哪些 attributes/properties(分子等)和 methods/functions(什么)?
在 Powershell 中,我会将变量通过管道传递给 get-member,例如: $num | get-member 并会显示所有属性和功能。

最好的方法是查阅文档了解 .WHAT 告诉您的任何类型,例如https://docs.perl6.org/type/Rat 对于 Rat.

如果您必须以编程方式拥有它,您可以使用 .^methods 向对象询问其方法。

> 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)

您可以使用 .^attributes 类似地查看属性 ('properties'),但是任何您应该访问的属性无论如何都会有访问器方法,所以您真的不需要这样做。