Skip to content

Commit 4d2f623

Browse files
committed
Document item
1 parent 158db97 commit 4d2f623

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

doc/Type/Any.pod6

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,27 @@ Exits the current process with return code C<$status>.
239239
240240
=comment TODO maybe find a better place to document &exit
241241
242+
=head2 sub item
243+
244+
X<|$ (item contextualizer)>
245+
246+
Defined as:
247+
248+
proto sub item(|) is pure
249+
multi sub item(\x)
250+
multi sub item(|c)
251+
multi sub item(Mu $a)
252+
253+
Forces given object to be evaluated in item context and returns the value of it.
254+
255+
dd item([1,2,3]); # $[1, 2, 3]
256+
dd item({ apple => 10 }); # ${:apple(10)}
257+
dd item("abc"); # "abc"
258+
259+
You can also use C<$> as item contextualizer.
260+
261+
say $[1,2,3] ~~ item([1,2,3]); # True
262+
242263
=end pod
243264

244265
# vim: expandtab shiftwidth=4 ft=perl6

doc/Type/Mu.pod6

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,16 @@ be re-evaluated with L<EVAL|/routine/EVAL> to regenerate the object). The exact
122122
C<perl> is implementation specific, since there are generally many ways to
123123
write a Perl expression that produces a particular value
124124
125+
=head2 method item
126+
127+
method item(Mu \item:) is raw
128+
129+
Forces the invocant to be evaluated in item context and returns the value of it.
130+
131+
dd [1,2,3].item; # $[1, 2, 3]
132+
dd { apple => 10 }.item; # ${:apple(10)}
133+
dd "abc".item; # "abc"
134+
125135
=head2 method clone
126136
127137
method clone(*%twiddles)

0 commit comments

Comments
 (0)