# Looping Problem

**URL:** <https://www.ruby-forum.com/t/looping-problem/171192>\
**Category:** Ruby\
**Created:** [June 28, 2009, 5:54am UTC](https://www.ruby-forum.com/t/looping-problem/171192 "2009-06-28T05:54:29Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ss\_1982](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/96bed5/32.png) [@ss\_1982](https://www.ruby-forum.com/u/ss_1982)\
**Post date:** [June 28, 2009, 5:54am UTC](https://www.ruby-forum.com/t/looping-problem/171192/1 "2009-06-28T05:54:29Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![ss\_1982](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/96bed5/32.png) [@ss\_1982](https://www.ruby-forum.com/u/ss_1982)\
**Post date:** [June 28, 2009, 6:50am UTC](https://www.ruby-forum.com/t/looping-problem/171192/2 "2009-06-28T06:50:49Z")

</div>

On Sat, Jun 27, 2009 at 8:56 PM, Scott  
Andrechek[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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.

---

<div class="post-metadata">

**Author:** ![ss\_1982](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/96bed5/32.png) [@ss\_1982](https://www.ruby-forum.com/u/ss_1982)\
**Post date:** [June 28, 2009, 7:01am UTC](https://www.ruby-forum.com/t/looping-problem/171192/3 "2009-06-28T07:01:39Z")

</div>

Thanks alot. It works perfect now 🙂

---

<div class="post-metadata">

**Author:** ![ss\_1982](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/96bed5/32.png) [@ss\_1982](https://www.ruby-forum.com/u/ss_1982)\
**Post date:** [June 28, 2009, 3:48pm UTC](https://www.ruby-forum.com/t/looping-problem/171192/4 "2009-06-28T15:48:56Z")

</div>

Hi,

Am Sonntag, 28. Jun 2009, 13:50:21 +0900 schrieb Christopher D.:

> On Sat, Jun 27, 2009 at 8:56 PM, Scott  
> Andrechek[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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
