From: Intransition Date: 2012-12-12T11:34:15+09:00 Subject: Re: Help me improve Hash#rekey ------=_Part_327_14496787.1355279122070 Content-Type: multipart/alternative; boundary="----=_Part_328_8771359.1355279122071" ------=_Part_328_8771359.1355279122071 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On Tuesday, December 11, 2012 6:55:32 AM UTC-5, Robert Klemme wrote: > > > > Oh, and nice use of polymorphism using #[] for both proc and hash > retrieval! > > Thank you! :-) > Well, everything went well except for one thing, which was a bit irritating actually -- I couldn't find a way to concisely handle a block with either one argument (just the key) or two arguments (the key and the value). Seems like that should be doable in one block call using a splat. But I had to have a condition on arity and two separate each_pair calls, one for each case. Maybe it's just not possible. In any case, thanks for your help! The code is looking much better. ------=_Part_328_8771359.1355279122071 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 7bit

On Tuesday, December 11, 2012 6:55:32 AM UTC-5, Robert Klemme wrote:

> Oh, and nice use of polymorphism using #[] for both proc and hash retrieval!

Thank you! :-)

Well, everything went well except for one thing, which was a bit irritating actually -- I couldn't find a way to concisely handle a block with either one argument (just the key) or two arguments (the key and the value). Seems like that should be doable in one block call using a splat. But I had to have a condition on arity and two separate each_pair calls, one for each case. Maybe it's just not possible.

In any case, thanks for your help! The code is looking much better.

------=_Part_328_8771359.1355279122071-- ------=_Part_327_14496787.1355279122070--