Closed oylenshpeegul closed 10 years ago
Yes, no accessors will be created unless you ask for them to be created.
I see. Thanks!
I guess I read here
http://blogs.perl.org/users/damien_dams_krotkine/2013/09/p5-mop.html
that you can add is, but it's really that you must.
Well, you don't need to generate an accessor if you are accessing the attribute in the class in which it is defined. For that you can simply access the variable directly, like so:
class Foo {
has $!bar;
method bar { $!bar }
}
But since they attributes are private the class in which they were defined, you cannot access it the same way in a subclass. This is where you would create an accessor (which yes, requires you to use the is
modifier and the ro
or rw
trait).
Ah. Thanks again!
Closing this as it seems the question has been answered and this is resolved.
When I run this code
I get an error
But if I change line 9 to
it works as expected