From: "Marcin Mielżyński" Date: 2006-03-05T09:03:39+09:00 Subject: Re: Simple Script Help (New to Ruby) Jordan Michaels wrote: > ---------------- > # set the default result > theResult = 0 > > # create the random number > theNumber = rand(10) > > while theResult != 3 > print "Guess my number: " > theGuess = gets.to_i > > # return key > # 1 = number is lower > # 2 = number is higher > # 3 = number matched! > if theNumber < theGuess > theResult = 1 > elseif theNumber > theGuess > theResult = 2 > elseif theNumber = theGuess > theResult = 3 > end > > case theResult > when 1 > puts "My number is lower." > when 2 > puts "My number is higher." > when 3 > puts "You guessed my number!" > end > > print "The Result: " > print theResult > print "\n" > > print "The Guess: " > print theGuess.class > print "+" > print theGuess > print "\n" > > print "The Number: " > print theNumber > print "\n" > end > ---------------- > (there is no elseif kayword but elsif) It seems to be working for me. You could replace the if/elsif statements with case statement case when theNumber < theGuess # blah when theNumber > theGuess # blah else # blah end lopex