From: Dave Thomas Date: 2001-04-28T05:22:33+09:00 Subject: [ruby-talk:14351] Re: case and to_s Jim Freeze writes: > Hi: > > I am trying to add a clase to a list depending upon the > type of the class. Since there are several types of > classes, I am using a case statement. But, the way I > am using the case statement causes the << to call > #to_s, which I don't want it to do. > Here is the error followed by the code. > Can someone please explain this behavior to me? > Tnanks > > ./dev.rb > ./dev.rb:21:in `===': failed to convert Class into String > (TypeError) > case d.type > when /DeviceA/ The good news is you can save some typing here: case d when DeviceA adadsasd when DeviceB etc.. The case statement will do the test DeviceA === d and so on. Class 'Module' defines === to check for instances, so all this just works out. Dave