From: Ryan Davis Date: 2011-06-25T05:20:02+09:00 Subject: Re: Honoring #to_ary and such On Jun 24, 2011, at 12:38 , Intransition wrote: > Well, for about the first time I am writing a library that has to be > very strict about types. Per the usual I am testing types with `case`, > e.g. > > def foo=(foo) > @foo = \ > case foo > when Array > foo > when String > [foo] > else > raise > end > end > > Now as I do this it occurs to me, shouldn't I also honor anything that > responds_to?(:to_ary) as an Array? And if so, what's the "usual" way > to handle it then? def foo= foo @foo = Array(foo) end