Hi,

My question is about passing parameters to .new method that do not
correspond to any field in class. This example;

use v6;

class PersonalId{
    has Int $.number;
    has Str $.full_name;
}

my Hash $p; #just because i'm scared of pair conversions
$p{"number"} = 13123123123;
$p{"full_name"} = "John Doe";
$p{"age"}=64;
$p{"shoesize"}=44;

say PersonalId.new(|%($p)).perl;
# PersonalId.new(number => 13123123123, full_name => "John Doe")

Works perfectly fine but I don't know whether I can rely on that. S12
speaks only about type objects: (It is allowed to pass type objects
that don't correspond to any parent class.)


-- 
Pozdrawiam

Kamil Kułaga

Reply via email to