In Any§
See primary documentation in context for sub item
multi item(\x)multi item(|c)multi item(Mu )
Forces given object to be evaluated in item context and returns the value of it.
say item([1,2,3]).raku; # OUTPUT: «$[1, 2, 3]»say item( %( apple => 10 ) ).raku; # OUTPUT: «${:apple(10)}»say item("abc").raku; # OUTPUT: «"abc"»
You can also use $
as item contextualizer.
say $[1,2,3].raku; # OUTPUT: «$[1, 2, 3]»say $("abc").raku; # OUTPUT: «"abc"»
In Mu§
See primary documentation in context for method item
method item(Mu \item:) is raw
Forces the invocant to be evaluated in item context and returns the value of it.
say [1,2,3].item.raku; # OUTPUT: «$[1, 2, 3]»say %( apple => 10 ).item.raku; # OUTPUT: «${:apple(10)}»say "abc".item.raku; # OUTPUT: «"abc"»