# Re: 99 bottles of beer...pg57

**URL:** <https://www.ruby-forum.com/t/re-99-bottles-of-beer-pg57/75139>\
**Category:** Ruby\
**Created:** [November 7, 2006, 7:09pm UTC](https://www.ruby-forum.com/t/re-99-bottles-of-beer-pg57/75139 "2006-11-07T19:09:32Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jamison\_edmonds](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/838e76/32.png) [@jamison\_edmonds](https://www.ruby-forum.com/u/jamison_edmonds)\
**Post date:** [November 7, 2006, 7:09pm UTC](https://www.ruby-forum.com/t/re-99-bottles-of-beer-pg57/75139/1 "2006-11-07T19:09:32Z")

</div>

Thanks :-}

----- Original Message ----  
From: Sammy L. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
To: ruby-talk ML [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Sent: Tuesday, November 7, 2006 11:57:01 AM  
Subject: Re: 99 bottles of beer…pg57

Hi Jamison,

The first thing I would do is remove the duplication with:

puts ‘99, Bottles of beer on the wall, 99 bottles of beer,’  
puts ‘take one down, pass it around,’

and put that in the loop. Since your code in the loop does the same  
thing, you could just decrement the value of first after printing the  
current lyrics, and let that only reside in 1 place instead of two.  
This way, if the song changes to something like “take one down, take a  
big swig and pass it around,” you only need to change it in one place.

Also, it doesn’t appear the “if first != 1” block will _never_ be  
executed (and I don’t see a need for it even if it was), so you could  
remove it and just decrement the value of first.

Finally, I think the variable name of first could be better named as to  
what it represents. After the first bottle of beer is removed from the  
wall, it no longer represents the first bottle. So, I might go with  
something like current\_bottle, or just anything that describes it better  
really.

-Sam
