When I declare a variable, whose value belongs to a built-in class, I simply write
my Int $a;
But when I want to use a user-defined class, I have to use Classname.new.
my class House {
has $.area is rw;
}
my $house1 = House.new;
$house1.area = 200;
say $house1.area;
So, my naïve question is, what's the reason of that difference? Why can't we simply write my House $house1?
My ultimate goal is to use an array whose values are instances of a user-defined class. How can I do the following correctly?
my @houses ...;
@houses[10].area = 222;