Hi,

Just playing around with pugs 6.2.5 OO and couldn't work this out:

class Bowl {
        has $.fish  is rw;
        has $.water is rw;
}
class Fish {
        has $.bowl    is rw;
        has $.eyes    is rw;
}

my $bowl   = Bowl.new;
my $blinky = Fish.new;

$bowl.water  = 'Murky';
$blinky.eyes = 3;

$bowl.fish   = $blinky;
$blinky.bowl = $bowl;

$bowl.water.say;
$blinky.eyes.say;

my $blinkys_bowl = $blinky.bowl;
$blinkys_bowl.water.say;

my $fishy = $bowl.fish;
$fishy.eyes.say;

$bowl.fish.eyes.say;
$blinky.bowl.water.say;

The output I get:

Murky
3
Murky
3
*** No compatible subroutine found: "&eyes"
    at Desktop/testOO.pl line 27, column 1-20

Am I missing something in the syntax when I try to chain the attribute methods? Or is this not implemented in pugs yet?

Thanks for any help.

Alex Gutteridge

EBI
Wellcome Trust Genome Campus
Hinxton
Cambs CB10 1SD
UK

Tel: 01223 492546
Email: [EMAIL PROTECTED]


Reply via email to