Skip to content

Instantly share code, notes, and snippets.

@softmoth
Created January 2, 2012 23:59
Show Gist options
  • Save softmoth/1552700 to your computer and use it in GitHub Desktop.
Save softmoth/1552700 to your computer and use it in GitHub Desktop.
submethod BUILD()
#! /usr/bin/env perl6
my %words = ();
class Vocab {
has Str $.word;
has Str @.synonyms = [];
submethod BUILD(:$!word, :@!synonyms, *@pos, *%nam) {
note "Vocab BUILD(): ", @pos.perl, %nam.perl;
%words{$!word} = self;
}
method Str {
return $.word;
}
method find(Str $word) {
return %words{$word};
}
}
#class Thing {
# has Vocab $.name;
# has Vocab @.desc;
#}
my Vocab $car .= new(:word<car>, :synonyms('auto', 'vehicle'));
Vocab.find('car').perl.say;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment