routine item

Documentation for routine item assembled from the following types:

class Any

From Any

(Any) sub item

Defined as:

multi item(\x)
multi item(|c)
multi item(Mu $a)

Forces given object to be evaluated in item context and returns the value of it.

say item([1,2,3]).perl;              # OUTPUT: «$[1, 2, 3]␤» 
say item( %apple => 10 ) ).perl;   # OUTPUT: «${:apple(10)}␤» 
say item("abc").perl;                # OUTPUT: «"abc"␤»

You can also use $ as item contextualizer.

say $[1,2,3].perl;                   # OUTPUT: «$[1, 2, 3]␤» 
say $("abc").perl;                   # OUTPUT: «"abc"␤»

class Mu

From Mu

(Mu) 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.perl;          # OUTPUT: «$[1, 2, 3]␤» 
say %apple => 10 ).item.perl# OUTPUT: «${:apple(10)}␤» 
say "abc".item.perl;            # OUTPUT: «"abc"␤»