Skip to content

Instantly share code, notes, and snippets.

@uasi
Created June 15, 2010 18:13
Show Gist options
  • Save uasi/439458 to your computer and use it in GitHub Desktop.
Save uasi/439458 to your computer and use it in GitHub Desktop.
use v6;
role Keyed[*@keys] is Associative {
my %index;
submethod BUILD() {
for @keys.kv -> $i, $v {
%index{$v} = $i;
}
}
multi method postcircumfix:<{ }>() {
self;
}
multi method postcircumfix:<{ }>(*@keys) {
my @result;
for @keys -> $key {
@result.push: self[%index{$key}];
}
@result;
}
}
my $a = [32, 64] but Keyed[<first second>];
$a<second>.say;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment