Re: Indirect method invocation



Hi,

Jan Eden wrote on 27.07.2005:

>In other words, I would like to have something like the %actions
>hash to construct a more flexible version of the $item->$mode()
>construct, where I can pass different additional parameters to each
>method.

I finally came up with something myself:

my %actions = (
display => sub { $item->display() },
move_picture => sub { $item->move_picture($item->{id}, $item->{parameters}->{position}) },
commit => sub { $item->commit() }
);

$actions{$parameters{mode}}->();

Thanks,

Jan
--
I used to have a Heisenbergmobile. Every time I looked at the speedometer, I got lost.
.



Relevant Pages

  • Re: Regardless of the result of the Ashes...
    ... Made a bit of a hash of it last. ... lost 1-0 but deserved to lose by a bigger margin than that. ... Prev by Date: ...
    (rec.sport.cricket)
  • Re: Time Calculations
    ... I do not appear to have any trouble with ... > Ideally I do not want to ann in date and times. ... Prev by Date: ...
    (microsoft.public.excel.worksheet.functions)
  • Re: Humble Contribution
    ... Phil Carmody writes: ... > I was following th edisussion until here, but you lost me here. ... > message with the same hash? ...
    (sci.crypt)
  • Re: Religion in SF
    ... perhaps we can hash out our own definition or agree to disagree. ... The All-New, All-Different Howling Curmudgeons! ... Prev by Date: ...
    (rec.arts.sf.written)
  • Re: Can use use value to find key (HashTable)
    ... and the key for the value in order to do a reverse lookup like ... >I have a hash table like: ... > Hashtable myHT = new Hashtable; ... Prev by Date: ...
    (microsoft.public.dotnet.languages.csharp)