daily pastebin goal
67%
SHARE
TWEET

Untitled

a guest Jul 11th, 2018 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ## Code
  2.  
  3. #which_category = gets.chomp
  4. #which_category.to_i
  5.  
  6. which_category = 0
  7. case which_category
  8.   when 0
  9.     puts "We are in case 0"
  10.   when 1
  11.   when 2
  12.   else
  13.     puts "Skipping File. Give it a category by running this script again."
  14. end
  15.  
  16. ## Question
  17.  
  18. When I hard code 0, the code runs as expected and outputs "We are in case 0" but when I do gets.chomp, it hits the else case.
  19.  
  20. I've tested puts which_category.inspect whose result is "0". I've tried which_category.to_i and it still went to the else case.
  21.  
  22. What obvious thing is this newbie missing?
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top