Recall the Wrong Proposals
Explore how to enhance your Ruby hangman game by storing wrong letter guesses in a collection. Learn to display these letters sorted alphabetically and without duplicates to improve game feedback and player experience.
We'll cover the following...
We'll cover the following...
Storing the wrong letters
Displaying the number of letters of the hidden word and the found letters is not enough to help the player. It’s also useful to show the wrong letters that they proposed. To do this, we are going to store the wrong letters in the same way as we accumulate the correct letters in a collection.
Let’s have a look at the updated code:
We add another collection named
wrong_lettersin line 6.We add the wrong letters in line 41, right after the display of the message saying that the letter is not in the hidden word. This ...