Hi Allen, thanks for your reply.
> First, toHash would probably fit prototype's style more. True, I guess. But it sounds as if it's a method to generically convert an Array to a Hash. This is not what I was trying to solve. As I said, I often run into situations where I want to further process the result of a Hash selection, e.g. after 'findAll'. I find such a method quite helpful. But I am completely undetermined with regard to the naming. > Second, in the implementation for hashify: > > else if (Object.isArray(item) && item.size()>0) hash.set(item[0], item[1]); > > This is disturbing to me, because if the array is 3 elements or more, you > essentially discard any values after the first two. Also true, but as above: 'hashify' is not intended to be a generic conversion function. However, this line may be superfluous and misleading. > Lastly, I think the biggest problem is that there are a thousand different > ways to convert an array to a hash and each person would find a different > one useful. ... > IMHO, this doesn't belong in core. I fully agree on that and maybe should have made myself more clear in my first post, sorry. I see the proposed method as some sort of glue to make working with Hashes easier (that's why I'd also included '$H' as an alias). Although I am not a big fan of chaining... Compare e.g. myHash.findAll(mySelector).hashify().keys(); to something like var result = $H(); $H(...).each(function(item) { if (mySelector(item)) result.set(item.key, item.value); }); result.keys(); (Yes, I know there is a way to access the keys in this case more easily, 'keys' here is just an example for a Hash method.) - Julian --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Prototype: Core" group. To post to this group, send email to prototype-core@googlegroups.com To unsubscribe from this group, send email to prototype-core-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-core?hl=en -~----------~----~----~----~------~----~------~--~---