--001485f78ae10602190467f5370c Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Thank you for this explanation. If I understand correctly, you want methods of Enumerable to remain as generic as possible and not assume anything of the elements (besides being comparable in some instances). I find this very reasonable indeed. Would Array#to_hash be more appropriate, then? Array has methods that assume some structure on elements of arrays. In particular, #assoc and #rassoc make the exact same kind of assumptions that #to_hash would make, and #transpose too. As for the name, I believe that either #to_hash or #to_h would be the most appropriate names, and the choice between one or the other depending on if a translation should occur automatically or not when calling Hash#replace and Hash::[]. (I think these are the only two?) If needed, I would be glad to reword this feature request for Array; it would be even simpler since no block would be needed and the behaviour the same as Hash::[]. I'm assuming that Hash::[] with an array of arrays is an official feature even though it's not yet documented (as per #1385), right? Thank you for your consideration, Marc-Andr On Sun, Apr 19, 2009 at 11:43 PM, Yukihiro Matsumoto <matz / ruby-lang.org>wrote: > Hi, > > In message "Re: [ruby-core:23253] Re: [Feature #666](Rejected) > Enumerable::to_hash" > on Sun, 19 Apr 2009 08:52:54 +0900, trans <transfire / gmail.com> > writes: > > |I don't see why a corresponance in needed. It's simply a > |transformation. > > #to_hash (or whatever name of the method) can only transform > enumerable in certain format, e.g. enumerable of two-elements arrays. > I think this is too much assumption for a method of Enumerable. > > OK, I admit we already have some methods with presumption, e.g. > #sort, #min and #max to assume elements to be comparable, but their > usefulness is proven in the history of the language. Meanwhile, how > often do we need #to_hash? I haven't, at least. > > |I think the real problem lies in the name of the > |method proposed. Rather than #to_hash, for instance, in Facets this > |method is called #graph or #mash (for "map hash"). Maybe there is a > |better name to be had, but it certainly is a useful method to have at > |times. > > Any method can be useful for certain situation. The point is how > often and in what situation it is useful. I don't see that much > usefulness to make it built in. > > matz. > > --001485f78ae10602190467f5370c Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Thank you for this explanation. If I understand correctly, you want methods of Enumerable to remain as generic as possible and not assume anything of the elements (besides being comparable in some instances). I find this very reasonable indeed.<br> <br> Would Array#to_hash be more appropriate, then? Array has methods that assume some structure on elements of arrays. In particular, #assoc and #rassoc make the exact same kind of assumptions that #to_hash would make, and #transpose too. <br> <br> As for the name, I believe that either #to_hash or #to_h would be the most appropriate names, and the choice between one or the other depending on if a translation should occur automatically or not when calling Hash#replace and Hash::[]. (I think these are the only two?)<br> <br> If needed, I would be glad to reword this feature request for Array; it would be even simpler since no block would be needed and the behaviour the same as Hash::[]. I'm assuming that Hash::[] with an array of arrays is an official feature even though it's not yet documented (as per #1385), right?<br> <br> Thank you for your consideration,<br> <br> Marc-Andrbr><br><div class="gmail_quote">On Sun, Apr 19, 2009 at 11:43 PM, Yukihiro Matsumoto <span dir="ltr"><<a href="mailto:matz / ruby-lang.org" target="_blank">matz / ruby-lang.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"> Hi,<br> <br> In message "Re: [ruby-core:23253] Re: [Feature #666](Rejected) Enumerable::to_hash"<br> <div> ¨ÂÓõî¬ ±¹ Áð²°°¹ °¸ºµ²ºµ´ «°¹°°¬ ôòáî¦ìô»¼á èòåæ½¢íáéìôïºôòáîóæéòåÀçíáéì®ãïíôáòçåô½¢ßâìáî뢾ôòáîóæéòåÀçíáéì®ãïí¼¯á¾¦çô÷òéôåóº¼âò<br> |I don't see why a corresponance in needed. It's simply a<br> |transformation.<br> <br> </div>#to_hash (or whatever name of the method) can only transform<br> enumerable in certain format, e.g. enumerable of two-elements arrays.<br> I think this is too much assumption for a method of Enumerable.<br> <br> OK, I admit we already have some methods with presumption, e.g.<br> #sort, #min and #max to assume elements to be comparable, but their<br> usefulness is proven in the history of the language. ¨Âåáî÷èéìåèï÷¼âòoften do we need #to_hash? ¨Â èáöå³¹»ô¬ áô ìåáóô®¼âò¾ <div><br> |I think the real problem lies in the name of the<br> |method proposed. Rather than #to_hash, for instance, in Facets this<br> |method is called #graph or #mash (for "map hash"). Maybe there is a<br> |better name to be had, but it certainly is a useful method to have at<br> |times.<br> <br> </div>Any method can be useful for certain situation. ¨Âèå ðïéîéó èï÷¼âòoften and in what situation it is useful. ¨Â äï³¹»óåôèáô íõãè¼âò¾ usefulness to make it built in.<br> <br> ¨Âáôú®¼âò¾ <br> </blockquote></div><br> --001485f78ae10602190467f5370c--