Subject: | Declaring hash attribute causes error when calling method |
Declaring an instance attribute as a hash, e.g.
class Foo {
has %bar is rw;
method baz (--> Str) { return "bat" }
}
Causes an error the first time a method other than 'new' is called:
my $foo = Foo->new; $foo->baz;
# Assigned value is not a reference at... (line no where the method being called was defined)
Nor is there any output that would help to identify the source of the issue. Adding an initializer to a reference value silences the error:
has %bar is rw = {};
--
-Jeff Ober