Skip to content

Instantly share code, notes, and snippets.

View cedric-vincent's full-sized avatar

Cédric Vincent cedric-vincent

View GitHub Profile
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 );
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"
=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
class Class { has $.attr; method attr() { !!! } }; Class.new(:attr(1));