Task/24-game/Ruby/24-game.rb
# for Ruby versions before 2.0
for Ruby versions before 2.0
for Ruby versions before 2 . 0
def play
  digits = Array.new(4){rand(1..9)}
  loop do
    guess = get_guess(digits)
    result = evaluate(guess)
    if result == 24.0
      puts "yes!"
      break
    else
      puts "nope: #{guess} = #{result}"
      puts "try again"
    end
  end
end
def play digits = Array . new ( 4 ) { rand ( 1 .. 9 ) } loop do guess = get_guess ( digits ) result = evaluate ( guess ) if result == 24.0 puts "yes!" break else puts "nope: #{guess} = #{result}" puts "try again" end end end
for Ruby versions before 2.0
for Ruby versions before 2 . 0