From: Yohanes Santoso Date: 2002-02-19T00:07:17+09:00 Subject: Re: hash question Markus Jais writes: > but this does not work. I thought that if this would work > it could be faster because the block is only called > for the keys which macht the regexp. I don't think there will be any improvement. Assuming that the syntax hash[/^b/].each works, then each element still has to be visited for matching. So, this moves the matching/checking from within the block to within the hash.each method. The only work saved is the call to method 'yield' from within #each. Total work is still largely the same: the computer has to check each element of the hash. If you have a large number of elements such that the overhead of performing yield to the block becomes significant, then most probably you should have refactored/restructure the way you store things. YS.