> On 13 May 2017, at 03:45, Brad Gilbert via RT <[email protected]>
> wrote:
> On Fri, 12 May 2017 03:04:46 -0700, elizabeth wrote:
>> <lizmat> m: class A { has Int $.a is default(42) }; dd A.new.a
>> # expected to see 42 there, not Int, so feels like "is default" on
>> attrs isn't implemented?
>
> It does work if you add =Nil
>
> class A { has Int $.a is rw is default(42) = Nil };
> dd A.new.a; # 42
> $_ = A.new(:a(34));
> .a = Nil;
> dd .a; # 42
The whole reason for me to look at this, was to prevent the explicit
initialization, done by BUILDALL. If you don’t, it still doesn’t work:
$ 6 'class A { has Int $.a is rw is default(42) = Nil }; say A.CREATE.a'
(Int)
:-(