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.
On Sat, Jun 27, 2009 at 8:56 PM, Scott
Andrechek[email protected] wrote:
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.
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 == answer3.upcase” as your condition. If you want to check
that a string is capitalized (which is slightly different), “answer3
== answer3.capitalize” is more likely to be what you want.
Thanks alot. It works perfect now
Hi,
Am Sonntag, 28. Jun 2009, 13:50:21 +0900 schrieb Christopher D.:
On Sat, Jun 27, 2009 at 8:56 PM, Scott
Andrechek[email protected] wrote:
while not answer3.upcase
…
end
The String#upcase method returns a string […].
“answer3 == answer3.upcase”
Untested:
class String
def is_upper?
self == upcase
end
end
Bertram