Jogo de advinhação em Ruby
✓ Published0🌍 Public
SSeralto
Last edited Mar 5, 2020
Created on May 9, 2016
This example demonstrates a Ruby number-guessing game where the player attempts to identify a random integer between 1 and 100. The program provides textual feedback after each guess, indicating whether the target number is higher or lower. The code uses `Random.rand` to generate the secret number, `gets.to_i` for player input, and conditional `puts` statements to guide the player. The refactored version replaces `if/else` logic with inline modifiers, showing a simplified alternative for the same feedback logic. The game loops until the player quits, tracking the number of attempts per round.
AI-generated description