Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Tree: 934a3db9d6
Fetching contributors…

Cannot retrieve contributors at this time

38 lines (25 sloc) 757 Bytes


role Has

Some of the core classes don't run through bless during object creation (apparently for efficiency reasons). This means that if you define a class that inherits from Array, for example, you can't define properties for the class using the normal has route.

The Has role addresses this by importing a new new that takes advantage of bless.


The following code breaks. If you try to access $.foo below, you get an undefined Any value instead of 'bar'.

class MySet is Array {
  has $.foo = 'bar';

say;    # Any()

Fix this with does Has from Class::Utils:

use Class::Utils;

class MySet is Array does Has {
  has $.foo = 'bar';

say;    # bar
Jump to Line
Something went wrong with that request. Please try again.