multiple array parameters to object methods?

Discussion in 'Perl Misc' started by en2guy@hotmail.co.uk, Jul 12, 2006.

  1. Guest

    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
    , Jul 12, 2006
    #1
    1. Advertising

  2. -berlin.de Guest

    <> 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
    -berlin.de, Jul 12, 2006
    #2
    1. Advertising

  3. Guest

    -berlin.de 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.
    , Jul 12, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Lew
    Replies:
    5
    Views:
    664
    Tom Anderson
    Jul 9, 2008
  2. Nikita Petrov
    Replies:
    2
    Views:
    110
    Gary Wright
    Apr 6, 2008
  3. Jason Lillywhite

    iterating methods on multiple parameters

    Jason Lillywhite, Sep 20, 2008, in forum: Ruby
    Replies:
    8
    Views:
    131
    Jason Lillywhite
    Sep 21, 2008
  4. Kenneth McDonald
    Replies:
    5
    Views:
    315
    Kenneth McDonald
    Sep 26, 2008
  5. Florian Loitsch
    Replies:
    11
    Views:
    246
    Michael Winter
    Mar 15, 2005
Loading...

Share This Page