Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^3: Assigning to a ArrayRef accessor type

by perlfan (Vicar)
on Sep 21, 2020 at 22:57 UTC ( [id://11122048]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Assigning to a ArrayRef accessor type
in thread Assigning to a ArrayRef accessor type

Okay, so what? Does it say, "There's no good reason to know how objects in Perl work."? My contention is simple, having this knowledge would likely result in some different choices being made depending on what is appropriate given the need.
  • Comment on Re^3: Assigning to a ArrayRef accessor type

Replies are listed 'Best First'.
Re^4: Assigning to a ArrayRef accessor type
by tobyink (Canon) on Sep 21, 2020 at 23:55 UTC

    This accessor could be implemented in two ways. I'm showing this as a read-only accessor because the read-write aspect isn't important for the example.

    sub files { return $_[0]{'files'}; } # OR sub files { return @{ $_[0]{'files'} }; }

    (And of course, there's the version that checks wantarray.)

    OP's problem is that he assumed Moo did it the second way, when it actually does it the first way. I don't see how learning to write constructors and accessors from scratch would have helped figure out what the issue was.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11122048]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (2)
As of 2024-04-19 20:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found