From: Scott Thompson Date: 2003-08-12T12:39:43+09:00 Subject: Re: using case with classes --Apple-Mail-2-748000944 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; format=flowed > def test( obj ) > case obj > when Array then puts "Array" > when Hash then puts "Hash" > when Class then puts "Class" > else puts "ugh" > end > end How about def test(obj) if [Array, Hash, Class].include?(obj.class) then puts obj.class.to_s else puts "ugh" end end I suspect that the case statement may be faster. Scott --Apple-Mail-2-748000944 Content-Transfer-Encoding: 7bit Content-Type: text/enriched; charset=US-ASCII def test( obj ) case obj when Array then puts "Array" when Hash then puts "Hash" when Class then puts "Class" else puts "ugh" end end How about def test(obj) if [Array, Hash, Class].include?(obj.class) then puts obj.class.to_s else puts "ugh" end end I suspect that the case statement may be faster. Scott --Apple-Mail-2-748000944--