On 16 Dec 2024, at 10:49, ToddAndMargo via perl6-users <perl6-us...@perl.org>
wrote:
Hi All,
In the following;
class Fruit {
has Str $.location is rw;
has UInt $.apples is rw;
has UInt $.oranges is rw;
has UInt $.bananas is rw;
}
# Pre-salted:
my $FruitStand = Fruit.new( location => "Cucamonga",
apples => 400,
oranges => 200,
bananas => 50 );
Is there a way in the class declaration that I can
set the default values such that the "my" creation
of the variable already has the default values in it?
Many thanks,
-T
On 12/16/24 02:27, Elizabeth Mattijsen wrote:
> class Fruit {
> has Str $.location is rw = "Cucamonga";
> has UInt $.apples is rw = 400;
> has UInt $.oranges is rw = 200;
> has UInt $.bananas is rw = 50;
> ``}
>
Thank you!