From: Joel VanderWerf Date: 2002-12-18T17:17:43+09:00 Subject: Re: Regex#=== with non-string argument Greg Millam wrote: > On Wed, 18 Dec 2002, Joel VanderWerf wrote: > > >>x = 1 >> >>case x >>when 5; puts "5" >>when 42; puts "42" >>when /abc/; puts "matches /abc/" >>when "xyz"; puts "xyz" >>end > > > x = 1 > puts case > when x == 5; "5" > when x == 42; "42" > when /abc/ =~ x.to_s; "matches /abc/" > when "xyz" == x.to_s; "xyz" > else "none" > end > > case without a statement matches any expression that evaluates to a > non-false, non-nil argument > > Hope that's what you want > - Greg. Thanks, but no. I happily discovered that fact a few days ago, but my real interest here is not case but a list of objects that respond to :=== (and that's all I know about them), and a piece of code that iterates over them looking for a match with a fixed object. I don't know whether that fixed object has a #to_s method, or what its semantics are, so I can't use it. Anyway, I don't want to lose the distinction between Object and "Object".