1 Replies - 1851 Views - Last Post: 31 January 2012 - 09:11 PM Rate Topic: -----

#1 AVReidy  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 65
  • View blog
  • Posts: 431
  • Joined: 17-February 11

Dumbfounded with simple syntax issue

Posted 31 January 2012 - 09:05 PM

I simply don't know what else to try. My conditional if statement isn't working for some reason, even though the values are equal...

    @input = gets()
    s = "List"

    if @input == s
      puts "You typed in List" #This code is NEVER reached
      list()
    else
      puts s + " " + @input
    end



I'd really appreciate some help. I shouldn't have such a problem in a language like Ruby.

Is This A Good Question/Topic? 0
  • +

Replies To: Dumbfounded with simple syntax issue

#2 xclite  Icon User is offline

  • LIKE A BOSS
  • member icon


Reputation: 894
  • View blog
  • Posts: 3,153
  • Joined: 12-May 09

Re: Dumbfounded with simple syntax issue

Posted 31 January 2012 - 09:11 PM

The problem is your input contains a newline. The actual value of the input is "List\n".

Try using @input = gets.chomp to remove the newline - it should work then.
Was This Post Helpful? 2
  • +
  • -

Page 1 of 1