Is there a perl6 instance of the powershells-get-member element to "parse" a variable (-object)?

Question: Is there / What is a Perl6 Powershells counterpart get-memberto β€œanalyze” variable attributes?

Explanation: In Perl 6, you can get the properties / attributes of a variable, for example:

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) 

How can I find out which attributes / properties (numerator, etc.) and methods / functions (WHAT) have a variable?
In Powershell, I would pass a variable get-member, for example: $num | get-memberand all properties and functions would be displayed.

+4
source share
1 answer

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

+6

Source: https://habr.com/ru/post/1678198/


All Articles