class Hamper { has $.name = 'Christmas Basket'; has @.items is rw = 'Mince Pie', 'White Wine', 'Stinky Cheese'; } my $hamper = Hamper.new; say "Name: " ~ $hamper.name; say "Items: " ~ $hamper.items; #### Name: Christmas Basket Items: Mince Pie White Wine Stinky Cheese #### has @.items[3] is rw = 'Mince Pie', 'White Wine', 'Stinky Cheese'; #### ===SORRY!=== Error while compiling /path/script.raku Defaults on compound attribute types not yet implemented. Sorry. Workaround: Create/Adapt TWEAK method in class Hamper, e.g: method TWEAK() { @!items := (initial values) unless @!items; } at /path/script.raku:3 #### class Hamper { has $.name = 'Christmas Basket'; has @.items[3] is rw; method TWEAK(){ @!items := 'Mince Pie', 'White Wine', 'Stinky Cheese' unless @!items; } } my $hamper = Hamper.new; say "Name: " ~ $hamper.name; say "Items: " ~ $hamper.items; #### Name: Christmas Basket Use of uninitialized value element[0] of type Any in string context. Methods .^name, .raku, .gist, or .say can be used to stringify it to something meaningful. in block at script.raku line 16 Use of uninitialized value element[1] of type Any in string context. Methods .^name, .raku, .gist, or .say can be used to stringify it to something meaningful. in block at script.raku line 16 Use of uninitialized value element[2] of type Any in string context. Methods .^name, .raku, .gist, or .say can be used to stringify it to something meaningful. in block at script.raku line 16 Items: #### Name: Christmas Basket Items: Mince Pie White Wine Stinky Cheese #### my $hamper = Hamper.new( items => ('Dog', 'Cat', 'Sausage') ); #### Name: Christmas Basket Items: Mince Pie White Wine Stinky Cheese #### method TWEAK(){ @!items := ('Mince Pie', 'White Wine', 'Stinky Cheese', 'Sardines', 'Dogfood'); } #### Name: Christmas Basket Items: Mince Pie White Wine Stinky Cheese Sardines Dogfood #### has Str @.items[3]; #### class Hamper { has $.name = 'Christmas Basket'; has Str @.items[3] is rw; method TWEAK(){ @!items := ('Mince Pie', 'White Wine', 'Stinky Cheese'); } } my $hamper = Hamper.new; say "Name: " ~ $hamper.name; say "Items: " ~ $hamper.items; #### Type check failed in binding; expected Positional[Str] but got List (("Mince Pie", "White...) in method TWEAK at script.raku line 9 in block at script.raku line 13