From: Joel VanderWerf Date: 2002-12-18T17:04:47+09:00 Subject: Regex#=== with non-string argument I'm surprised: x = 1 case x when 5; puts "5" when 42; puts "42" when /abc/; puts "matches /abc/" when "xyz"; puts "xyz" end This is a TypeError. Is there any good reason why? I think it would make sense for Regex#=== (if not Regex#=~) to return false for non-Strings. Otherwise, this kind of case statement has to be broken into an 'if..else..end' and two 'case...end' statements. Anyway this workaround is no good for me because, instead of a case statement, I have a list of given objects which respond to :===. I guess I could test for Regex, but that's not very elegant. Also, I can't just rescue TypeError, because I can't be sure that a given (user-supplied) object uses TypeError in this way (and maybe the TypeError is a programming error inside the user's #=== implementation). The same goes for Range#=== .