From: Charles Comstock Date: 2004-07-07T17:17:36+09:00 Subject: Re: Class#=== has interesting results > > whatisit = case obj > when Array > "it's an array!" > when Hash > "it's a hash!" > when Septuagenarian > "it's a septuagenarian!" > end > > $ ri Module#=== > ------------------------------------------------------------- Module#=== > mod === obj => true or false > ------------------------------------------------------------------------ > Case Equality---Returns +true+ if _anObject_ is an instance of > _mod_ or one of _mod_'s descendents. Of limited use for modules, > but can be used in +case+ statements to classify objects by class. > Right I was trying to use it in an example almost exactly like that except that obj was a name of a commandclass. Ie: def parse(str) input = str.chomp.split comm = CommandFactory[input[0]] case comm when StartCommand comm.new(input[1],input[2..-1]) @mobile = input[1] when HelpCommand else comm.new(@mobile,input[1..-1]) end end The idea was for a command factory to return the name of the command, and instantiate that command with the rest of the string as parameters, except for a few special case examples which would be checked against in a case statement. Since StartCommand === StartCommand returns false this doesn't work. Why you would want == to return true and === to return false in this case is beyond me. I knew about the example you gave above, that was what I was trying to emulate except at a step before. Charles Comstock