|
|
|
|
|
by b2gills
1755 days ago
|
|
The `but` keyword takes an instance and something to mix into it. So you can say something like this: 0 but True
---Since `True` is a `Bool` it automatically creates a role that has a method `Bool` that returns `True`. my $role = role { method Bool { True }}
You can do that manually if you want. 0 but role { method Bool { True }}
---It creates a new subclass of Int and mixes in the role. So: 0 but True
Is roughly equivalent to: do {
my constant but-true = anon role { method Bool { True }}
my $class = anon class :: is Int does but-true {}
$class.new( 0 )
}
|
|