Why dosnt this work

Hey guys

I get an error on this code:

def print_options
     puts "What do you want to do? Enter the number of the program you
want to run."
     puts "1. Show different classes."
     puts "2. Search for a student."
end

def showclasses
     classlists = Dir.glob "*txt"
     puts "Which class do you want to view?"
     puts classlists
     classanswer = gets.chomp.downcase
     classlists.each do |klass|
         pupils = Files.readlines klass
         if klass == classanswer
             puts "The following students are in #{klass.gsub(".txt",
":")}"
             puts pupils
         end
     end
end

def studentsearch
     classlists = Dir.glob "*txt"
     puts "Type in the student you want to search for."
     search = gets.capitalize
     classlists.each do |klass|
     elever = File.readlines(klass)
         if elever.include? search
             puts "#{search.chomp} is in #{klass.gsub(".txt", ".")}"
         end
     end
end

print_options

answer = gets.chomp

options = case answer
     when "1" then showclasses
     when "2" then studentsearch
end

it's the 'def showclasses' part that causes me problems. The loop dosnt
work for some reason and I dont get why : /

···

--
Posted via http://www.ruby-forum.com/.

it's the 'def showclasses' part that causes me problems. The loop dosnt
work for some reason and I dont get why : /

Add some 'puts' or 'p' statements to your code in strategic places, e.g.
just before, inside, and after the loop.

  p klass

  p pupils

  p klassanswer

etc. ('p foo' is short for 'puts foo.inspect')

···

--
Posted via http://www.ruby-forum.com/\.