题:
是否/ Power shells get-member的Perl6对应物是什么来“分析”变量的属性?
是否/ Power shells get-member的Perl6对应物是什么来“分析”变量的属性?
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)