From: Rick DeNatale Date: 2010-04-13T21:55:31+09:00 Subject: Re: My application doesn't work well On Mon, Apr 12, 2010 at 8:35 PM, Bruno Santana wrote: > I ran the application and appears that: > > -bash-4.0$ ruby pedrapapeltesoura.rb > Digite pedra, papel ou tesoura: pedra > 1 > pedra > pedra > alguem ganhou > > the number 1 above is the content of the variable resultSorteio, the > first word "pedra" is the content of the variable maquina and the second > "pedra" is the content of the variable usuario. According to the code > below when both variables contain the value "pedra" it should be shown > "empatou", however appears "alguem ganhou". am I comparing the strings > properly? > >  if usuario == maquina then >                        puts("empatou") >                else >                        puts("alguem ganhou") >                end > > The whole code is in my previous post. Thanks. Well, it looks like the two values really aren't the same. Two observations. If there is trailing whitespace in one of the values the puts statements won't show this. You're printing the values before you alter one of them. To get a better debugging perspective try changing puts(maquina) puts(usuario) usuario.chop to usuario.chop p(maquina) p(usuario) Which will show the 'inspect' output of the two values right before you compare them. -- Rick DeNatale Blog: http://talklikeaduck.denhaven2.com/ Github: http://github.com/rubyredrick Twitter: @RickDeNatale WWR: http://www.workingwithrails.com/person/9021-rick-denatale LinkedIn: http://www.linkedin.com/in/rickdenatale