From: ishamid Date: 2006-11-27T13:35:13+09:00 Subject: simple loops and recursion Hi, I'm a total newbie, and this is my very first message. I'm going through Chris Pine's Learn to Program; almost half done. Problem: Consider the following working code: =============== def repeat type number_of_bottles = '99' while number_of_bottles != '0' puts number_of_bottles.to_s + ' bottles:' + ' If one falls, ' + (number_of_bottles.to_i - 1).to_s + ' bottles.' type + (number_of_bottles.to_i - 1).to_s + ':' number_of_bottles = gets.chomp end end repeat 'Type ' =============== I want to add a recursion conditional: If there are 98 bottles left, one should type '98'; if there are 97, one should type '97' etc. At 0 bottles the programs ends. What I want is an additional conditional recursion, so that e.g. if, at 98 bottles, I type anything other than '98', the program recursively tells me to type '98' until I type '98'. Every way I've tried this gives me a " undefined local variable or method `number_of_bottles' " type of error, or else the program keeps going back to 99. Thanks in advance Idris