Skip to main content
100%

Jogo de advinhação em Ruby

✓ Published0🌍 Public
SSeralto
Last edited May 9, 2016
Created on May 9, 2016

This example shows a Ruby terminal word-guessing game where the player must uncover a randomly selected word from a fixed list of ten animal names. The game displays a partially hidden word as underscores, prompts for letter guesses, and reveals correct matches iteratively. It uses Ruby core methods such as `Array#sample` to choose the word, `Array#times` with a block to build the underscore pattern, `String#each_char` to iterate through the target word’s letters, and `Array#join` with `String#count` to detect remaining blanks. The code runs purely via standard input/output with `gets.chomp`, and loops until the word is fully guessed or the player opts to restart.

AI-generated description

Similar vizzes