Please create an account to participate in the Slashdot moderation system


Forgot your password?

Slashdot videos: Now with more Slashdot!

  • View

  • Discuss

  • Share

We've improved Slashdot's video section; now you can view our video interviews, product close-ups and site visits with all the usual Slashdot options to comment, share, etc. No more walled garden! It's a work in progress -- we hope you'll check it out (Learn more about the recent updates).


Journal: 99 bottles of beer, in ruby

Journal by Inigo Montoya

I recently came across this website about 99 bottles of beer in many different programming languages:
  which seems to have the most complete list (621 versions, albeit some dups).

However, I recently started to learn ruby this month, and I didn't like the ruby example at that site, so I thought I'd write my own. Here it is for all it's fun.

class Wall
  attr_reader :beers, :s
  def initialize
    @beers = 99
    @s = "s"
  def getAbeer
    puts "#{beers} bottle#{s} of beer on the wall."
    puts "#{beers} bottle#{s} of beer."
    puts "Take one down, pass it around,"
    @beers = @beers - 1
    s = "s" unless @beers == 1
    puts "#{beers} bottle#{s} of beer on the wall.\n\n"
    @s = s
  def noMoreBeer
    return @beers == 0
wall =
wall.getAbeer until wall.noMoreBeer

So, how did I do? I think mine is 99 times better than the one at that site. Yes, I know my version is not the most efficient because it has excess assignments. But it is clean and easy to read, without the clutter of if/then/endif statements. Besides, you want it to be slow and inefficient, the beer lasts longer :)

Journal: Mod points

Journal by Inigo Montoya
Wow. Today I got mod points, for the first time since I joined Slashdot, many years ago.

Oddly, I don't even remember when I joined. I know I didn't post enough, but I sure read alot. However, I never received mod points until after I started posting, and I started doing more of that recently.

Wow. Did I say that already :)

Decaffeinated coffee? Just Say No.