RosettaCodeData/Task/Add-a-variable-to-a-class-instance-at-runtime/Perl-6/add-a-variable-to-a-class-instance-at-runtime-2.pl6

5 lines
159 B
Raku
Raw Permalink Normal View History

2013-04-10 22:43:41 -07:00
my $lue = 42 but role { has $.answer = "Life, the Universe, and Everything" }
say $lue; # 42
say $lue.answer; # Life, the Universe, and Everything