From: Brian Candler Date: 2010-07-11T01:08:55+09:00 Subject: Re: if statements and case statements questions Kenneth     wrote: > Ruby switches expand to the === operator, for example: > > case string > when "" then puts "Empty" > when /^a/ then puts "Starts with a" > end > > is equivalent to: > > if string === "" > puts "Empty" > elsif string === /^a/ > puts "Contains a" > end Actually the arguments are the other way round: if "" === string puts "Empty" elsif /^a/ === string puts "Starts with a" end Another example: case arg when String; puts "it's a string" when Numeric; puts "it's a number" end The first expands to String === arg, which is functionally equivalent to arg.is_a?(String) -- Posted via http://www.ruby-forum.com/.