From: Peter Hickman Date: 2013-04-12T00:28:52+09:00 Subject: Re: confusion with gets, if --089e0163541050c07804da17713a Content-Type: text/plain; charset=ISO-8859-1 If you put "p input" just after you get the input you will see "10\n". That is the newline on the end. Remove it with input = gets.chomp # removes the "\n" It's a common beginners problem with Ruby. A string from input will include the new line on the end and it either needs to be removed (with chomp) or handled in some way. --089e0163541050c07804da17713a Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
If you put "p input" just after you get the inpu= t you will see=A0"10\n". That is the newline on the end. Remove i= t with

input =3D gets.chomp # removes the "\n= "
It's a common beginners problem with Ruby. A string from inp= ut will include the new line on the end and it either needs to be removed (= with chomp) or handled in some way.

--089e0163541050c07804da17713a--