Hi,

Jeremy W. wrote in post #1061681:
>
> Probably the easiest way is:
> http://ruby-doc.org/core-1.9.3/Object.html#method-i-kind_of-3F
>
> You might also want to consider:
> http://ruby-doc.org/core-1.9.3/Object.html#method-i-respond_to-3F

To explain this a bit: In Ruby you usually don't judge objects by their 
"type" (class) but by the existance of certain methods. This is called 
duck typing.

The idea behind this is that the *behaviour* of an object matters, not 
so much the class. For example, most of the time it isn't important if 
an object is actually an array. It might as well be an instance of any 
other class, as long as it *behaves* like an array (is enumerable, 
implements the "[]" method to access elements etc.). So instead of 
asking "Is this an array?", you ask "Does this have an each method?" 
etc.

However, in your case it's probably best to explicitly check for the 
Array class and the String class (or a subclass).

-- 
Posted via http://www.ruby-forum.com/.