Re: Customizable default hash and array values.
by Dan Sugalski other posts by this author
Sep 25 2001 10:53PM messages near this date
Re: Customizable default hash and array values.
|
Re: Customizable default hash and array values.
At 10:06 PM 9/24/2001 -0400, Michael G Schwern wrote:
> Wouldn't it be nice if there was a way to change the default value of
> a hash? So instead of undef you'll get whatever default you like?
Sure, I don't see why not. The hash access function is responsible for
returning a value, so there's no reason you shouldn't be able to override
it. Whether that's a core feature now is another issue, of course, but
there won't be anything to stop you. You can also do trickery to not
autovivify elements of the array or hash if they're only read and don't exist.
I'm pretty sure you can do this now with tie, but that's kind of heavy-weight.
Dan
--------------------------------------"it's like this"-------------------
Dan Sugalski even samurai
dan@[...].org have teddy bears and even
teddy bears get drunk
Thread:
Michael G Schwern
RaFaL Pocztarski
Johan Vromans
Bart Lateur
Michael G Schwern
Bart Lateur
Michael G Schwern
Dan Sugalski
David Grove
|