From: "Mauricio Fernández" Date: 2002-12-02T20:21:22+09:00 Subject: Re: Array !== Array? On Mon, Dec 02, 2002 at 07:20:05PM +0900, Tim Bates wrote: > What is the rationale behind Array === Array (or indeed any other class) being > false? Array.new === Array is also false. How do I test what class some > object is in a case statement? irb(main):001:0> a = [] [] irb(main):002:0> case a irb(main):003:1> when Array irb(main):004:1> puts "Array" irb(main):005:1> when Hash irb(main):006:1> puts "Hash" irb(main):007:1> end Array nil ie, in case a when B ... when C ... end the comparison being done is B === a, not a === B. It just makes sense that irb(main):008:0> Array === Array.new true And of course irb(main):009:0> Array === Array false because Array is not an instance of class Array but of class Class irb(main):010:0> Class === Array true -- _ _ | |__ __ _| |_ ___ _ __ ___ __ _ _ __ | '_ \ / _` | __/ __| '_ ` _ \ / _` | '_ \ | |_) | (_| | |_\__ \ | | | | | (_| | | | | |_.__/ \__,_|\__|___/_| |_| |_|\__,_|_| |_| Running Debian GNU/Linux Sid (unstable) batsman dot geo at yahoo dot com win-nt from the people who invented edlin. -- MaDsen Wikholm, mwikholm@at8.abo.fi