PuffedRiceCrackers
PuffedRiceCrackers

Reputation: 785

What difference does curly brace make in accessing an object

Not even sure if I used the right terminology.. This was the passed data.

$bug = bless({
'bug_id' => '25252',

'flag_types' => [
    bless({
      'name' => 'name1',
      'flags' => [bless({
        'id' => 488052,
      }, 'Bugzilla::Flag')],
    }, 'Bugzilla::FlagType'), 
    bless({
      'name' => 'name2',
      'flags' => [bless({
        'id' => 488053,
      }, 'Bugzilla::Flag')],
    }, 'Bugzilla::FlagType'), 
  ],

}, 'Bugzilla::Bug');

Why can I reference name with or without curly braces, but not the flags? $_->flags gives error

Can't locate object method "flags"
                my @isCrash = map { 
                    print Dumper($_->name);
                    print Dumper($_->{name});
                    print Dumper($_->flags); # errors
                    print Dumper($_->{flags};                    
                } @{ $bug->{flag_types} };

I get that flags is not a method, but why is it that I don't get such an error for name?

Upvotes: 2

Views: 83

Answers (1)

Tekki
Tekki

Reputation: 351

Your array contains objects of type Bugzilla::FlagType, they have a method name that "Returns the name of the flagtype".

Upvotes: 4

Related Questions