Skip to content

Commit b53bf82

Browse files
committed
Provide a few examples
And complete definition to make it clearer.
1 parent 7192e48 commit b53bf82

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

doc/Type/Positional.pod6

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,32 @@
44
55
=SUBTITLE Object that supports looking up values by index
66
7-
role Positional { ... }
7+
role Positional[::T = Mu] { ... }
88
9-
Role for objects which support indexing them using the L«C< [ ] > postcircumfix operator|/language/operators#postcircumfix_[_]»
10-
(usually list-like objects). Example types with Positional role
11-
include L<List|/type/List>, L<Array|/type/Array>, L<Range|/type/Range>, and L<Buf|/type/Buf>.
9+
Role for objects which support indexing them using the
10+
L«C< [ ] > postcircumfix operator|/language/operators#postcircumfix_[_]»
11+
(usually list-like objects). Example types with Positional role
12+
include L<List|/type/List>, L<Array|/type/Array>, L<Range|/type/Range>,
13+
and L<Buf|/type/Buf>.
1214
1315
=head1 Methods
1416
1517
=head2 method of
1618
1719
method of()
1820
19-
Returns the type constraint for elements of the positional container. Defaults
20-
to L<Mu|/type/Mu>.
21+
Returns the type constraint for elements of the positional container, that
22+
is, the C<T> in the definition above, which, as it can be seen, defaults
23+
to L<Mu|/type/Mu>. It is returned as a type object.
2124
22-
=head1 Methods that should be provided
25+
=for code
26+
my @þ;
27+
say @þ.of.^name; # OUTPUT: «Mu␤
28+
my Str @þð;
29+
say @þð.of.raku; # OUTPUT: «Str␤»
30+
say (my int @).of; # OUTPUT: «(int)␤»
31+
32+
=head1 Methods that should be provided by classes that mix in this role
2333
2434
=head2 method elems
2535

0 commit comments

Comments
 (0)