From: John Sheahan Date: 2007-12-03T02:56:42+09:00 Subject: Running -r in IRB After doing a couple of websites using Rails, I realized that my problem is that I am terrible at ruby so I bought "Ruby by Example" by Kevin Baird and started on page 1. I'm at the part in chapter 2 where I am being instructed to run -r in irb to include a required class file and I'm getting the following error: irb(main):001:0> -r 99bottles.rb SyntaxError: compile error (irb):1: syntax error, unexpected tINTEGER, expecting kDO or '{' or '(' -r 99bottles.rb ^ from (irb):1 When I run the file 99bottles.rb from the command prompt it doesn't do anything but gives me no errors. I believe that since the file creates a new class, the book wants me to require the file so I can run new commands against the new class in the 99bottles.rb file. I am including the contents of the 99bottles.rb file as well...If anyone can help point me in the right direction with including a class into irb using -r with this file, I would be very grateful. thanks jackster -------------------------99bottles.rb-------------------------- #!/usr/bin/env ruby # 99 bottles problem in Ruby class Wall def initialize(num_of_bottles) @bottles = num_of_bottles end =begin rdoc Predicate, ends in a question mark, returns Boolean. =end def empty?() @bottles.zero? end def sing_one_verse!() puts sing(' on the wall, ') + sing("\n") + take_one_down! + sing(" on the wall.\n\n") end private def sing(extra='') "#{(@bottles > 0) ? @bottles : 'no more'} #{(@bottles == 1) ? 'bottle' : 'bottles'} of beer" + extra end =begin rdoc Destructive method named with a bang because it decrements @bottles. Returns a String. =end def take_one_down!() @bottles -= 1 'take one down, pass it around, ' end end -- Posted via http://www.ruby-forum.com/.