develooper Front page | perl.fwp | Postings from November 2007

Re: fun with hashes!

Thread Previous | Thread Next
From:
Mr. Shawn H. Corey
Date:
November 23, 2007 17:01
Subject:
Re: fun with hashes!
Message ID:
47477782.40108@magma.ca
A. Pagaltzis wrote:
> * Mr. Shawn H. Corey <shawnhcorey@magma.ca> [2007-11-24 00:50]:
>> my $sub = ( exists $dispatch{ $key } && ref( $dispatch{ $key } ) eq 'CODE' )
>>          ? $dispatch{ $key }
>>          : $dispatch{ 'default' };
>>
>> Just because you're not paranoid doesn't mean computers don't
>> hate you :)
> 
> So why did you skip the check for whether the default value is
> a CODE ref?

Because I don't like dispatch tables.  When I see them I want to convert the whole thing to objects and starting thinking about inheritance and polymorphism.  Which will take care of such problems at "compile" time.

But this thread is about hashes not objects.

(And I still think computers hate me.)


-- 
Just my 0.00000002 million dollars worth,
  Shawn

+------------\
| Shangri La  \
| 40,000 km   /
+------------/

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About