by orf · 3y ago · 0 comments
class Point {
has [qw/x y/] => ( default => sub { 0 } );
sub clear ($self) {
$self->@{ 'x', 'y' } = ( 0, 0 );
}
}
What? class Point {
has $x = 0;
has $y = 0;
sub clear {
$x = $y = 0;
}
}
At least that's how I implemented it in the future perl, called cperl. Designed with perl6.
His perl cannot have array or hash fields, and his fields are still hash keys. Wtf class Point {
field ( $x, $y ) :param = 0;
method clear () {
( $x, $y ) = ( 0, 0 );
}
}If you want classes go use java or C#, the second and third most boring things in programming.