use v6; class test { has @.x; method new($r) { my $tmp = self.bless(*,:$r); return $tmp,@!x.elems; } submethod BUILD(:$r) { @!x.push(^$r.rand); } } my ($x,$y) = test.new(10); say $x.x.perl; say $y;