On 1/2/07, Johannes Fredborg <johannes_room / hotmail.com> wrote: > Okay guys! > I am pritty new to Ruby programing and i need your help. > > Is it possibel to ask the program to go back to another program line > number and then proceed from there? > > an exampele: > > ans1 = gets.chomp <----------------- (proceed from here) > if ans1 == 'black' > co1 = 0 > puts > puts 'type in the next color' > ans2 = gets.chomp > end > > if ans1 == 'brown' > co1 = 1 > puts > puts 'type in the next color' > ans2 = gets.chomp > end > > if co1 == nil > puts > puts 'Not acepted, please retype the color' > goto.line 1 <------------------------------ (this was just a wild wild > guess) > end > ... > ... > > Do you see what i mean? is this possibel to do. Or is there another way > that I can achieve the same effect? > > Any help? Thanks! > Johannes- Here's a hint as to how you can do this without a "goto". It looks to me like you want to keep prompting as long as you haven't set co1, right? See if you can fill in the ... blanks below to get what you're aiming for. -Alex co1 = nil while co1.nil? do ans1 = gets.chomp case ans1 when 'black' ... when ... ... else ... end end # now that we know we got co1, let's get the next color puts 'type the next color' ans2 = gets.chomp ...