Reflection

why doesn’t this work:

···

####################################
class Test
def foo_bar(x)
puts x
end
end

test = Test.new

puts 'guess the method:'
while gets
if test.respond_to?($_)
puts 'correct!'
exit
end
puts 'incorrect guess, please try again:'
end

puts 'guess the method:'
while gets

        # there is a \n at the end and you've forgotten to remove it
        chomp!

     if test.respond_to?($_)
         puts 'correct!'
         exit
     end
     puts 'incorrect guess, please try again:'
end

Guy Decoux

why doesn’t this work:

while gets

  $_.chomp!
if test.respond_to?($_)

Regards,

Brian.

···

On Sun, Jun 08, 2003 at 11:22:37PM +0900, culley harrelson wrote: