Skip to content

Instantly share code, notes, and snippets.

@MadcapJake
Created November 25, 2015 19:21
Show Gist options
  • Save MadcapJake/0089315a03c13e30c514 to your computer and use it in GitHub Desktop.
Save MadcapJake/0089315a03c13e30c514 to your computer and use it in GitHub Desktop.
Perl 6 Private Methods
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