Created
January 2, 2012 23:59
-
-
Save softmoth/1552700 to your computer and use it in GitHub Desktop.
submethod BUILD()
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /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