This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class C { has $.value; method succ { !!! } }; | |
my C $x .= new(value => 2); | |
my C $y .= new(value => 4); | |
my C $z .= new(value => 3); | |
multi sub infix:<cmp> (C:D $a, C:D $b) { 'debug'.say; $a.value cmp $b.value } | |
say ?( $x cmp $y ); | |
say ?( $z ~~ $x .. $y ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
role R { }; | |
my $x = 4 but R; | |
my $y = 2 but R; | |
multi sub foo ($a, $b) { say "foo without constraint" } | |
multi sub foo ($a where { .defined and .does(R) }, | |
$b where { .defined and .does(R) }) { | |
say "foo with constraints" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=begin POD | |
=head1 Whatever the layout manager is | |
=head2 Introduction | |
This article aims to demonstrate how C<Whatever> -- one of the many | |
interesting Perl 6 curiosities -- could be useful to easily implement | |
and use complex things like a layout manager. In a couple of words, a | |
layout manager is the part of a graphical interface in charge of the |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Class { has $.attr; method attr() { !!! } }; Class.new(:attr(1)); |