3 ms·
I think Perl 6 aka Raku allows this, you can say something like `Person but $age < 18`.
by dash2 5y ago
I think Perl 6 aka Raku allows this, you can say something like `Person but $age < 18`.
- lizmat 5y agoI think the you mean: `subset Minor of Person where *.age < 18`
- b2gills 5y agoThe `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 ) }