From: Jeremy Heiler Date: 2011-06-25T07:04:39+09:00 Subject: Re: Honoring #to_ary and such On Fri, Jun 24, 2011 at 4:09 PM, Intransition wrote: > On Jun 24, 3:57 pm, Jeremy Heiler wrote: > >> It depends. Do you want to? I suppose the only disadvantage would be >> the cost of an object possibly creating a new array when to_ary is >> invoked. > > No, I don't really ;-) But... I've always been under the impression > that something that responds to #to_ary should be treated as such. > Thanks to duck-typing I've never really had to give it much thought > before. That sounds reasonable, but I still think it depends on what you're really trying to do. Iv'e always considered #to_ary to mean: "transform my state into an array, which may or may not be expensive." In which I would leave it up to the programmer to decide if they want to call #to_a, and let it fail if they don't. My opinion here would be different if it meant: "here's my state as an array, which I have been keeping up-to-date all along.