From: Phrogz Date: 2006-11-04T13:00:06+09:00 Subject: Re: How to simplify "a.instance_of? classX or a.instance_of? classY " Stephane Wirtel wrote: > I would like to know if there is a way to simplify this code > > object.instance_of? WSDL::XMLSchema::ComplexContent or > object.instance_of? WSDL::XMLSchema::ComplexType or > object.instance_of? WSDL::XMLSchema::SimpleType or [snip] case object when WSDL::XMLSchema::ComplexContent, WSDL::XMLSchema::ComplexType, WSDL::XMLSchema::SimpleType # your code here end For example: irb(main):001:0> class Foo; end; class Bar; end; class Jimmy; end => nil irb(main):002:0> o = Bar.new => # irb(main):003:0> case o; when Foo, Bar; p "yay"; else; p "boo"; end "yay" => nil irb(main):004:0> o = Jimmy.new => # irb(main):005:0> case o; when Foo, Bar; p "yay"; else; p "boo"; end "boo" => nil