You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
22:42 hoelzro if the default logic happens after BUILD, then $!server is Str because BUILD doesn't set it up via its signature
22:43 m: class Person { has $.name = 'John'; has $.age = 21; submethod BUILD(:$!name) { say $!age } }; say Person.new(:name<Rob>)
22:43 camelia rakudo-moar d410e3: OUTPUT«(Any)Person.new(name => "Rob", age => Any)»
...
22:43 hoelzro m: class Person { has $.name = 'John'; has $.age = 21; submethod BUILD() { say $!age } }; say Person.new(:name<Rob>)
22:43 camelia rakudo-moar d410e3: OUTPUT«(Any)Person.new(name => "John", age => Any)»
...
22:43 Juerd Right, but that would mean that I can't use any of the defaulting logic if I want other stuff to happen at initialization, using those defaults...
22:43 hoelzro hmm...that's interesting
22:43 m: class Person { has $.name = 'John'; has $.age = 21; submethod BUILD() { } }; say Person.new(:name<Rob>)
22:43 camelia rakudo-moar d410e3: OUTPUT«Person.new(name => "John", age => 21)»
22:43 Juerd I can only imagine that this is an extremely common use case.
...
22:44 hoelzro it looks like referring to any attributes in BUILD circumvents their defaulting logic, which seems...odd.
...
22:44 Juerd I could just add the defaults to BUILD's signature, but it's so nice to have them all in one place :(
22:44 hoelzro Juerd: I think that's a rakudobug
Migrated from rt.perl.org#126680 (status was 'new')
Searchable as RT126680$
The text was updated successfully, but these errors were encountered: