Created
November 25, 2015 19:21
-
-
Save MadcapJake/0089315a03c13e30c514 to your computer and use it in GitHub Desktop.
Perl 6 Private Methods
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 Human { | |
has $.name; | |
has $!age; | |
method age { | |
($!age * 0.8).round; | |
} | |
method new (:$name, :$age) { self.bless(:$name, :$age); } | |
} | |
my $john = Human.new(name => 'John', age => 35); | |
say $john; #=> Human.new(name => "John") | |
say $john.name; #=> John | |
say $john.age; #=> 0 | |
#!> Use of uninitialized value of type Any in numeric context | |
#!> in method age at /home/jrusso/exercism/human.p6:5 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment