Looping Problem

S

Scott Andrechek

Hi. I'm new to ruby and i am trying to get a while not loop to occur if
the answer i got from gets wasn't capatalized. This is what i have now:

while not answer3.upcase
puts "WHAT!"
answer3=gets
end

It's not working and i've also tried answer3= .upcase and such. Thanks
in advance for the help.
 
C

Christopher Dicely

Hi. I'm new to ruby and i am trying to get a while not loop to occur if
the answer i got from gets wasn't capatalized. This is what i have now:

while not answer3.upcase
=C2=A0puts "WHAT!"
=C2=A0answer3=3Dgets
end

It's not working and i've also tried answer3=3D .upcase and such. Thanks
in advance for the help.


The String#upcase method returns a string which is equal to the string
it is called on with all the letters converted to upper case. If you
want to check that a string has no lowercase letters, you could use
"answer3 =3D=3D answer3.upcase" as your condition. If you want to check
that a string is capitalized (which is slightly different), "answer3
=3D=3D answer3.capitalize" is more likely to be what you want.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,521
Members
44,995
Latest member
PinupduzSap

Latest Threads

Top