On Fri, Jun 24, 2011 at 3:38 PM, Intransition <transfire / gmail.com> 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.
>
>  > @foo = \
> case foo
> when Array
>  
> when String
>  
> else
> raise
> 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?

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.

It might be worth letting the user decide with a second `force =
false` parameter.

I am also wondering, what makes a String special here as opposed to a
Fixnum or any other object?