Guest User

Untitled

a guest
Jul 11th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  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?
Add Comment
Please, Sign In to add comment