subscript adverb :k

Documentation for subscript adverb :k, assembled from the following types:

language documentation Subscripts

From Subscripts

(Subscripts) subscript adverb :k

Return only the index/key of the element, rather than its value, and silently skip nonexistent elements:

my @tens = 0102030;
say @tens[1]:k;        # OUTPUT: «1␤» 
say @tens[042]:k;  # OUTPUT: «(0 2)␤» 
 
my %month = Jan => 1Feb => 2Mar => 3;
say %month<Feb>:k;          # OUTPUT: «Feb␤» 
say %month<Jan Foo Mar>:k;  # OUTPUT: «(Jan Mar)␤» 

If you don't want to skip nonexistent elements, use the negated form:

say %month<Jan Foo Mar>:!k;  # OUTPUT: «(Jan Foo Mar)␤» 

See also the keys routine.