From: Martin DeMello Date: 2009-12-02T15:43:25+09:00 Subject: Re: How Do I Change a .gsub On Wed, Dec 2, 2009 at 11:46 AM, Dylan Rodriguez wrote: > I'm trying to make a Hangman game > > def guessed_word() > >        word_letters = @word.split("") >  blank = @word.gsub(/[a-z]/, '_') > >  return blank > end > > the array for the correct guesses made by the user is @good_guesses and > incorrect is @bad_guesses > > So, my game will print out the right number of blanks for however many > letters are in the word...but I don't know how to add the elements from > @good_guesses into the correct spots. > > I've tried things like > > if @word.include?(@good.guesses) >   right = blank.gsub(/[_]/, @good_guesses.split) > end Try maintaining the word as an array. Here's a basic sketch: class Hangman def initialize(word) @word = word.split // @good_guesses = {} end def display_word @word.map {|i| @good_guesses[i] ? i : "_"}.join(" ") end def guess(letter) if @word.include? letter @good_guesses[letter] = true end end end martin