You can use regular expressions, such as e.g. finding a type of string.:
case foo when /^(true|false)$/ puts "Given string is boolean" when /^[0-9]+$/ puts "Given string is integer" when /^[0-9\.]+$/ puts "Given string is float" else puts "Given string is probably string" end Ruby caseRuby's case will use the equality operand === for this (thanks @JimDeville) also info . Additional information is available at "hereRuby Operators". This also can be done using @mmdemirbas example (without parameter) just, only this approach is cleaner for these types of cases.