Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Class::Struct accessor function after Perl V5.16

by Anonymous Monk
on Jan 02, 2019 at 12:15 UTC ( [id://1227914]=note: print w/replies, xml ) Need Help??


in reply to Class::Struct accessor function after Perl V5.16

Thanks for you comments.
So I think I can fix it by checking parameters in set_values with
if (@_&& ref @_ ne ‘ARRAY’) {

Replies are listed 'Best First'.
Re^2: Class::Struct accessor function after Perl V5.16
by haukex (Archbishop) on Jan 02, 2019 at 15:08 UTC
    if (@_&& ref @_ ne ‘ARRAY’) {

    No, not quite, ref @_ won't do what you want. If you wanted to check that a function was called with exactly one argument that is an arrayref: if ( @_==1 && ref $_[0] eq 'ARRAY' ) { ... }

      Sorry, I forgot to mention that set_heights, apart from initialization stage, is called passing a list of key/value pairs.
      So
      if (@_ && ref $_[0] ne 'ARRAY') {
      is now fixing the code. Thanks a lot for your time and help.

Log In?
Username:
Password:

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

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

    No recent polls found