in reply to Re: Using ArrayRef data members in Moose
in thread Using ArrayRef data members in Moose

True.

By way of contrast, I figured out the sugar for using HashRefs. Hit on this by "genetic programming" -- trying different things until something worked:

$obj->count_by_word()->{$word} = $count;
It would be great if there was something similarly simple for arrayref access -- I'm suspecting that there is, and I just haven't found it.

Replies are listed 'Best First'.
Re^3: Using ArrayRef data members in Moose
by karavelov (Monk) on Jul 01, 2008 at 23:38 UTC
    I think that it works quite the same with arrayrefs:
    $obj->weight()->[0] = 10;
Re^3: Using ArrayRef data members in Moose
by stvn (Monsignor) on Jul 03, 2008 at 02:40 UTC
    By way of contrast, I figured out the sugar for using HashRefs.

    This is not sugar at all, this is just how HASH refs work. The "count_by_word" accessor is simply returning the HASH ref value that is stored, nothing more nothing less.

    -stvn
      Ah, yes. Now I get it. Thanks.

      And thanks also to karavelov for the example.