Created
June 28, 2014 09:14
-
-
Save ChoHag/5bf910fa4b04d51bfa5f to your computer and use it in GitHub Desktop.
Fake hash
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
class fakehash { | |
has $.keys handles 'push'; | |
has $.calculator = { $^a }; | |
has $.null; | |
method postbrace ($lookup) { | |
$lookup ~~ $.keys.any ?? $!calculator($lookup) !! $.null; | |
} | |
} | |
sub postcircumfix:<{ }> (fakehash $bar, $lookup) { | |
$bar.postbrace($lookup); | |
} | |
say fakehash.new(calculator => sub {$^a~2}, keys => <<a b c d>>)<a> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment