Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > multiple array parameters to object methods?

Reply
Thread Tools

multiple array parameters to object methods?

 
 
en2guy@hotmail.co.uk
Guest
Posts: n/a
 
      07-12-2006
Hi-

trying to understand object oriented perl, and have been wondering
about passing arrays as parameters to object methods.

If I pass a single array as a method parameter, it's fine, eg

$object->raiseFlags(@flags);

However, if I wanted to pass 2 arrays to an object method, I would have
to use references to objects, I think, since

$object->raiseFlags(@flags, @specialOccasions);

would append @specialOccasions to @flags to make a big jumbled list.

Are there any issues to using references as method parameters when
using objects in perl? Is there a better way to approach the problem?

Thanks

 
Reply With Quote
 
 
 
 
anno4000@radom.zrz.tu-berlin.de
Guest
Posts: n/a
 
      07-12-2006
<> wrote in comp.lang.perl.misc:
> Hi-
>
> trying to understand object oriented perl, and have been wondering
> about passing arrays as parameters to object methods.
>
> If I pass a single array as a method parameter, it's fine, eg
>
> $object->raiseFlags(@flags);
>
> However, if I wanted to pass 2 arrays to an object method, I would have
> to use references to objects, I think, since


Not to objects, necessarily, but array refs are the standard way
of handing in more than one array to a perl sub. Whether the sub
is a method or not is irrelevant.

> $object->raiseFlags(@flags, @specialOccasions);
>
> would append @specialOccasions to @flags to make a big jumbled list.
>
> Are there any issues to using references as method parameters when
> using objects in perl?


No.

> Is there a better way to approach the problem?


Other ways, yes. Better, no.

Anno
 
Reply With Quote
 
 
 
 
en2guy@hotmail.co.uk
Guest
Posts: n/a
 
      07-12-2006

wrote:
> <> wrote in comp.lang.perl.misc:
> > Hi-
> >
> > trying to understand object oriented perl, and have been wondering
> > about passing arrays as parameters to object methods.
> >
> > If I pass a single array as a method parameter, it's fine, eg
> >
> > $object->raiseFlags(@flags);
> >
> > However, if I wanted to pass 2 arrays to an object method, I would have
> > to use references to objects, I think, since

>
> Not to objects, necessarily, but array refs are the standard way
> of handing in more than one array to a perl sub. Whether the sub
> is a method or not is irrelevant.
>
> > $object->raiseFlags(@flags, @specialOccasions);
> >
> > would append @specialOccasions to @flags to make a big jumbled list.
> >
> > Are there any issues to using references as method parameters when
> > using objects in perl?

>
> No.
>
> > Is there a better way to approach the problem?

>
> Other ways, yes. Better, no.
>
> Anno


thanks for the feedback, Anno.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Object creation - Do we really need to create a parent for a derieved object - can't the base object just point to an already created base object jon wayne C++ 9 09-22-2005 02:06 AM
does a "parameters"-parameter overwrite the "parameters"-object? Florian Loitsch Javascript 11 03-15-2005 03:33 PM
Passing derived class object array in place of base class object array justanotherguy63@yahoo.com C++ 9 12-03-2004 10:57 PM
Servlet parameters different from the command line parameters? Jonck van der Kogel Java 2 05-26-2004 11:34 PM
Problem assigning an Array object to an Array-subclass object Richard Lionheart Ruby 27 05-04-2004 06:42 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57