# Re: Learn to Program, by Chris Pine

**URL:** <https://www.ruby-forum.com/t/re-learn-to-program-by-chris-pine/93390>\
**Category:** Ruby\
**Created:** [April 1, 2006, 7:17am UTC](https://www.ruby-forum.com/t/re-learn-to-program-by-chris-pine/93390 "2006-04-01T07:17:00Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![William\_SBillS\_Froe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/e0b2c6/32.png) [@William\_SBillS\_Froe](https://www.ruby-forum.com/u/William_SBillS_Froe)\
**Post date:** [April 1, 2006, 7:17am UTC](https://www.ruby-forum.com/t/re-learn-to-program-by-chris-pine/93390/1 "2006-04-01T07:17:00Z")

</div>

First off, thanks to Dave for providing the explanation that should have  
been in place of just my solution.

I also recommend putting the “beer = beer - 1” at the end of the loop  
but that won’t immediately allow you to remove the if unless you also  
look at changing the loop criteria or provide a special check to handle  
the last time through the loop. Assuming you want to end with 0 bottles  
of beer on the wall, then your last iteration through the loop will need  
to be when beer = 1 which means you should also look to change your  
while criteria. Either of the following would work:

While beer \>= 1

Or

While beer \> 0

Both of these will allow you to remove the extra if check.

Keep it up!

–Bill
