title: Handling Ruby Case Statement
body: <p>I tried to rewrite the "if/else statement" in the following piece of code by replacing it with a "case" statement, and I am deadly stuck with it for a few hours - what am I missing? </p>
  
  <pre><code>puts "Welcome to 'Guess My Number!'"
  print "What is your name?"
  input = gets
  name = input.chomp
  
  puts "Welcome, #{name.upcase!}!"
  puts "I've got a random number between 1 and 100!"
  puts "Can you guess it?"
  target = rand(100) + 1 
  
  num_guesses = 0
  guessed_it = false
  until num_guesses == 10 || guessed_it
      remaining_guesses = 10 - num_guesses
      puts "You've got #{remaining_guesses.to_s} guesses left!"
      print "Make a guess, put down a number: "
      guess = gets.chomp.to_i
      num_guesses = num_guesses + 1
  end
  
  puts case verification
      when guess &lt; target 
          then "Ooops. Your guess was LOW."
      when guess &gt; target
          then "Ooops. Your guess was HIGH."
      when guess &lt; -1 
          then puts "Oooops. You have entered a number lower that 1!"
      when guess &gt; 100
          then puts "Oooops. You have entered a number higher than 100!"
      when guess =~ /^([w])/
          then puts "Ooops. Looks like you have entered a non numeric 
  value!"
      when guess == String
          then puts "Oooops! Looks like you have entered a non numeric 
  value"
  
      when guess == target 
          then puts "Good job, #{name}!"  
               puts "You guessed my number in #{num_guesses} guesses!"
               guessed_it = true
  end
  
  unless guessed_it
      puts "Sorry, you didn't get my number. My number was #{target}."
  end
  </code></pre>
  
  <p>The "case statement" was used to replace and enhance the logic of the following if else statement:</p>
  
  <pre><code>if guess &lt; target
      puts "Ooops. Your guess was LOW."
   elsif guess &gt; target
    puts "Ooops. Your guess was HIGH."
   elsif guess == target 
    puts "Good job, #{name}!" 
    puts "You guessed my number in #{num_guesses} guesses!"
    guessed_it = true
   end
  </code></pre>