In Mu§

See primary documentation in context for method bless

method bless(*%attrinit --> Mu:D)

Low-level object construction method, usually called from within new, implicitly from the default constructor, or explicitly if you create your own constructor. bless creates a new object of the same type as the invocant, using the named arguments to initialize attributes and returns the created object.

It is usually invoked within custom new method implementations:

class Point {
    has $.x;
    has $.y;
    multi method new($x$y{
        self.bless(:$x:$y);
    }
}
my $p = Point.new(-11);

In this example we are declaring this new method to avoid the extra syntax of using pairs when creating the object. self.bless returns the object, which is in turn returned by new. new is declared as a multi method so that we can still use the default constructor like this: Point.new( x => 3, y => 8 ).

For more details see the documentation on object construction.