An idea of Moose enumerators (about Native::Trait)
A note about features about Moose::Attribute::Native::Trait.
package Stuff; use Moose; has options => ( traits => ['Array'], is => 'ro', isa => 'ArrayRef[Str]', default => sub { [] }, handles => { each_options => 'kv', # two at a time }, ); 1; # and later package main; my $stuff = Stuff->new(); # ... my $iterator = $stuff->each_options(); while(my($k, $v) = $iterator->next()){ # ... } # or $stuff->each_options(sub{ my($k, $v) = @_; # ... ); __END__
Just like as Ruby's enumerators.