Brad Fitzpatrick (brad) wrote,
Brad Fitzpatrick
brad

Fun bug

Here's a fun bug. See if you can find what's happening:
my @data = function();
my @sorted = sort { $a->method <=> $b->method } @data;

foreach my $item (@sorted) {
    $item->other_method;
}

The error message I was getting:

Can't call method "other_method" on undefined value at line ...

The question to you is: how is that possible?

I think you'll smile if/when you realize the answer.
Tags: perl, tech
Subscribe
  • Post a new comment

    Error

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.
  • 25 comments