in reply to Re: Function Prototypes and Array vs. List (Pt. 2)
in thread Function Prototypes and Array vs. List (Pt. 2)
create(id)So, I have an array @bob = ('Bob') which I want to use on this function. Eyeballing it, it looks like it would fit, so I go ahead and use it:
Creates a Foo object with the id parameter set accordingly. id should be a valid record identifier.
Foo::create(@bob);Do you get a warning? Nope. Yet later, you might notice that for some reason your Foo has an id of 1, which doesn't make any sense. Maybe smoke starts pouring out of your Perl program because of acalar conversion induced program failure. You lose a life and must hit "P1 Start" to continue.
Instead, you're going to have to do some work, which is anti-Lazy. In the general sense:Foo::create(listify(@bob)); # List converter? Foo::create($bob[0..$#bob]); # Array slice as list?
Foo::bar($baz[0],$baz[1],$baz[2],...,$baz[$#baz]);
|
---|
Replies are listed 'Best First'. | |
---|---|
•Re: Re^2: Function Prototypes and Array vs. List (Pt. 2)
by merlyn (Sage) on Jun 13, 2002 at 14:38 UTC | |
by Abigail-II (Bishop) on Jun 13, 2002 at 16:01 UTC | |
by tadman (Prior) on Jun 14, 2002 at 04:46 UTC | |
by danger (Priest) on Jun 14, 2002 at 07:43 UTC | |
Re: Re^2: Function Prototypes and Array vs. List (Pt. 2)
by ariels (Curate) on Jun 13, 2002 at 14:47 UTC | |
by Abigail-II (Bishop) on Jun 13, 2002 at 16:13 UTC |