Skip to content

Instantly share code, notes, and snippets.

@librasteve
Created February 22, 2024 05:04
Show Gist options
  • Save librasteve/0ec5bb2a70bc545faca830ec91baca92 to your computer and use it in GitHub Desktop.
Save librasteve/0ec5bb2a70bc545faca830ec91baca92 to your computer and use it in GitHub Desktop.
How to use sub capture and gather together
sub dims-match( @a ) {
given @a {
when *== 0 { '' }
when *== 1 { .first }
when *>= 2 { .&type-hint }
}
}
gather {
for $.dictionary.type-to-dims.kv -> $key, $value {
take $key if $value eqv self.dims
}
} ==> dims-match
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment