Here is my code:
@cmd == "exit"
when @cmd is a string variable “exit” it doesn’t return true. Any suggestions why?
-Edit-
-Resolved
Error: Because @cmd was made by using ‘@cmd = gets’ it added ‘\n’ to @cmd. Thanks for your help!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
@cmd must contain something other than exit. Is it possible that @cmd contains some kind of whitespace character like a newline or space? Perhaps try:
If @cmd is being set from $stdin.readline, then it will likely have the newline character in it. Stripping and chomping will help eliminate uncertainty.