
package Text::Wigwam::Stash::Base::Magic::Array;

use strict;
use warnings;
no warnings 'uninitialized';

our $VERSION = '0.01';

use base 'Text::Wigwam::Stash::Base::Magic';

sub Keys     { [ 0..$#{$_[1]} ] }
sub Values   { [ @{$_[1]} ] } # return a copy
sub Sort     { [ sort @{$_[1]} ] }
sub Reverse  { [ reverse @{$_[1]} ] }
sub Join     { join( ", " => @{$_[1]} ) }
sub Rand     { $_[1][rand @{$_[1]}] }
sub Pop      { pop @{$_[1]} }
sub Shift    { shift @{$_[1]} }
sub Size     { scalar @{$_[1]} }
sub Distinct {
    my %done;
    [ grep { !$done{$_}++ } @{$_[1]} ];
}

sub DEFAULT { $_[1]->[$_[2]] }

1;
