Perlで返り値を安易に補完しない方が良かった話

my @array = $self->array || ();
sub array {
    my @array = (1, 2, 3);
    return @array;
}

my @array = array() || ();
print "@array";
sub array {
    my @array = (1, 2, 3);
    return @array;
}

my @array = array();
print "@array";

Comments

comments powered by Disqus