2010/1/20 Xeno Campanoli <xeno.campanoli / gmail.com>: > I'm looking for a way to make sure an object being passed is in some class > family, or to say it otherwise, inherits some specific class, but not > necessarily directly. ¨Βζαγτιτ γουμβε ηςεατηςεατηςαξδπαςεξγμασσ¬ > and that would be okay, and needs to be okay. ¨Βτθεςσονετθιξχθεςεαταλε αξ οβκεγτ αξηο > > unless object.inherits?(MyClass) > ¨Βαισε ΣωξταψΕςςος¬ Άετγ®Ά > end First of all that would not be a SyntaxError because the syntax is not affected. Using this error type will create misleading error messages. Here are all the ways that I am aware of (trying to summarize what others have posted so far): irb(main):010:0> a = [] => [] irb(main):011:0> a.class.ancestors => [Array, Enumerable, Object, Kernel, BasicObject] irb(main):012:0> a.class.ancestors.include? Enumerable => true irb(main):013:0> a.kind_of? Enumerable => true irb(main):014:0> a.is_a? Enumerable => true irb(main):015:0> Enumerable === a => true irb(main):016:0> Note that I do not recommend using the test from line 12 as it is likely much more inefficient than the other ones. The test from line 15 is especially suited for use with "case" statements as in case a when Enumerable puts "it's enumerable" when Array, Hash puts "It's a special enumerable" when Integer puts "You can count on me." else puts "No idea about a." end Another note: more often than not it is not necessary to test for the type of an object. You rather invoke those methods on it that you expect it to implement. You will get an exception anyway if the object does not implement the method (NoMethodError). You can find more details about this concept under the label "duck typing", e.g. http://en.wikipedia.org/wiki/Duck_typing Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/