On 04/03/2012 08:24 PM, Daniel Carrera wrote:
> On 3 April 2012 17:24, Moritz Lenz <mor...@faui2k3.org> wrote:
>> You can, very nearly. You just need to write
>>
>> my @vec is Vector;
>>
>> because you really want to change the type of the container, not just of the
>> contents (my Vector @vec would be an array containing Vector objects).
> 
> 
> Another option might be to just use scalar variables to hold vectors:
> 
> my Vector $vector;
> my Vector @array_of_vectors;
> 
> $vector = 1,2,3,4,5;

but then you don't get list assignment semantics for that last line, so
it'll parse as ($vector = 1), 2, 3, 4, 5;

> Doesn't work for me :-(  For me the last statement gives "12".

which version of Rakudo are you using? (I've tried on the last
development version from git)

> 
>> (you can also override the .STORE method of a scalar, but that's a bit
>> creepy if you ask me).
> 
> Hmm...  So you'd have to mess with the STORE method of *all* scalars
> (i.e. not just the Vector() class) ?

No. Just those that you want to behave specially. And I never
recommended it.

Cheers,
Moritz

Reply via email to