Let’s assume we have a type with multi-component name, like:

class Foo::Bar {
}

And there is another class Baz for which we want it to be coercible into Foo::Bar. No problem!

class Baz {
    method Foo::Bar() { Foo::Bar.new }
}

Now we can do:

sub foo(Foo::Bar() $v) { say $v }
foo(Baz.new);

Comments