- or download this
class Hamper {
has $.name = 'Christmas Basket';
...
say "Name: " ~ $hamper.name;
say "Items: " ~ $hamper.items;
- or download this
Name: Christmas Basket
Items: Mince Pie White Wine Stinky Cheese
- or download this
has @.items[3] is rw = 'Mince Pie', 'White Wine', 'Stinky Cheese';
- or download this
===SORRY!=== Error while compiling /path/script.raku
Defaults on compound attribute types not yet implemented. Sorry.
...
@!items := (initial values) unless @!items;
}
at /path/script.raku:3
- or download this
class Hamper {
has $.name = 'Christmas Basket';
...
say "Name: " ~ $hamper.name;
say "Items: " ~ $hamper.items;
- or download this
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 s
+omething meaningful.
in block <unit> at script.raku line 16
Items:
- or download this
Name: Christmas Basket
Items: Mince Pie White Wine Stinky Cheese
- or download this
my $hamper = Hamper.new( items => ('Dog', 'Cat', 'Sausage') );
- or download this
Name: Christmas Basket
Items: Mince Pie White Wine Stinky Cheese
- or download this
method TWEAK(){
@!items := ('Mince Pie', 'White Wine', 'Stinky Cheese', 'Sardines'
+, 'Dogfood');
}
- or download this
Name: Christmas Basket
Items: Mince Pie White Wine Stinky Cheese Sardines Dogfood
- or download this
has Str @.items[3];
- or download this
class Hamper {
has $.name = 'Christmas Basket';
...
say "Name: " ~ $hamper.name;
say "Items: " ~ $hamper.items;
- or download this
Type check failed in binding; expected Positional[Str] but got List ((
+"Mince Pie", "White...)
in method TWEAK at script.raku line 9
in block <unit> at script.raku line 13