From: ishamid Date: 2006-11-28T07:00:07+09:00 Subject: Re: simple loops and recursion I leave this as a exercise for the reader... Ok, here is the solution to the exercise :-) ============== def expect(msg, expected_value) puts "#{msg}#{expected_value}:" loop do actual_value = gets.chomp return actual_value.to_i if actual_value.to_i == expected_value puts "Sorry, expected #{expected_value} but got #{actual_value}" end end # expect('We want ', 98) # test def repeat(msg) number_of_bottles = 99 while number_of_bottles != 0 do puts "#{number_of_bottles} bottles: If one falls, #{number_of_bottles - 1} bottles." number_of_bottles = expect(msg, number_of_bottles - 1) end end repeat('We want ') ============== If I input a string, it comes back as a string, and everything else works too. Thank you again for this lesson! Now I will study David's approach... Thnx again and Best Idris