From: cremes.devlist@... Date: 2006-12-05T02:57:37+09:00 Subject: Re: help, my 'case/when' code doesn't work On Monday, December 04, 2006, at 11:44AM, "Stefano Crocco" wrote: >Alle 18:33, luned� 4 dicembre 2006, cremes.devlist@mac.com ha scritto: >> def case_test(obj) >> print "testing via case... " >> case obj.class >> when Array >> puts "obj is a #{obj.class}" >> when String >> puts "obj is a #{obj.class}" >> else >> puts "obj is unknown: #{obj.class}" >> end >> end > >Your code will call Array===obj.class. According to ri aClass===anObject >returns true if anObject is an instance of aClass or of one of its >descentents (which more or less means if anObject.is_a?(aClass) returns >true). Because of this, all your 'when' statements will fail, because >obj.class is not an instance of Array or String. To do what you want, you >should substitute > > case obj.class > >with > > case obj Sheesh! I *knew* it was something easy. I feel like a dope... cr