Created
February 22, 2013 20:09
-
-
Save jnthn/5016208 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 FreezeHash { | |
has $.hash handles *; | |
method new(*@args) { self.bless: *, hash => Hash.new: @args } | |
method at_key(FreezeHash:D: $key is copy) is rw { | |
$!hash.exists($key) or warn "Cannot set non-existing key '$key'"; | |
$!hash.at_key($key); | |
} | |
} | |
my $fh = FreezeHash.new: "a" => 1, "b" => 2; | |
say $fh.perl; | |
say $fh<a>; | |
$fh<c> = 3; | |
say $fh<c>; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment