To me your test shows that you CAN'T reach lower than the start of the array
I'd love to see what's your definition "can" in this situation. Let's say you're right and you can't reach before the start of the array. What would be returned if you could?
To me, "can" would be returning what's at that location. It correctly returns undef.
Unless I can figure out how to differentiate a tied call from a direct one.
sub FETCH {
my ($self, $i) = @_;
return $self->_fetch($i);
}
sub fetch {
my ($self, $i) = @_;
$i += $self->num_eles() if $i < 0;
return undef if $i < 0;
return $self->_fetch($i);
}
sub _fetch {
my ($self, $i) = @_;
# $i is guaranteed to be in range
...
}
|