# Not a Ruby person but trying to help a newbie

**URL:** <https://www.ruby-forum.com/t/not-a-ruby-person-but-trying-to-help-a-newbie/154615>\
**Category:** Ruby\
**Created:** [December 2, 2008, 5:30am UTC](https://www.ruby-forum.com/t/not-a-ruby-person-but-trying-to-help-a-newbie/154615 "2008-12-02T05:30:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![charlie2869](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/bc8723/32.png) [@charlie2869](https://www.ruby-forum.com/u/charlie2869)\
**Post date:** [December 2, 2008, 5:30am UTC](https://www.ruby-forum.com/t/not-a-ruby-person-but-trying-to-help-a-newbie/154615/1 "2008-12-02T05:30:02Z")

</div>

Hi there

I am a C++ person but trying to help a friend using Ruby.  
He is supposed to ask for user input by using an index number to change  
the letter of a word given, like say “dog”. So the user it asked to  
enter the index number, lets say 0 is entered by the user, and he then  
asks the user to put a new letter in (letter is a variable), then he  
wants to change the index of 0 which is the “D” to a “C” (where c was  
put in by the user).

Can anyone help with this? How to do it please?

Cheryl

---

<div class="post-metadata">

**Author:** ![charlie2869](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/bc8723/32.png) [@charlie2869](https://www.ruby-forum.com/u/charlie2869)\
**Post date:** [December 2, 2008, 5:32am UTC](https://www.ruby-forum.com/t/not-a-ruby-person-but-trying-to-help-a-newbie/154615/2 "2008-12-02T05:32:05Z")

</div>

Cheryl Cepak wrote:

> Hi there
> 
> I am a C++ person but trying to help a friend using Ruby.  
> He is supposed to ask for user input by using an index number to change  
> the letter of a word given, like say “dog”. So the user it asked to  
> enter the index number, lets say 0 is entered by the user, and he then  
> asks the user to put a new letter in (letter is a variable), then he  
> wants to change the index of 0 which is the “D” to a “C” (where c was  
> put in by the user).
> 
> Can anyone help with this? How to do it please?
> 
> Cheryl

Here is what he has so far:

student\_name = ‘John Wallace’  
puts student\_name + “'s WordWarp Game!”  
require ‘zlib’  
dictionary = Zlib::GzipReader.open(‘words3-8.gz’).read().split()  
current\_word = ‘dog’  
target\_word = ‘cat’

puts  
puts current\_word.to\_s + ’ =\> ’ + target\_word.to\_s

puts ‘What is the index of the letter you wish to change?’  
index = gets  
puts ‘What letter do you wish to insert?’  
letter = gets  
temp\_word = current\_word.clone()

puts temp\_word

---

<div class="post-metadata">

**Author:** ![charlie2869](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/bc8723/32.png) [@charlie2869](https://www.ruby-forum.com/u/charlie2869)\
**Post date:** [December 2, 2008, 6:56am UTC](https://www.ruby-forum.com/t/not-a-ruby-person-but-trying-to-help-a-newbie/154615/3 "2008-12-02T06:56:07Z")

</div>

On Tue 2.Dec’08 at 13:24:28 +0900, Cheryl Cepak wrote:

> I am a C++ person but trying to help a friend using Ruby.  
> He is supposed to ask for user input by using an index number to change  
> the letter of a word given, like say “dog”. So the user it asked to  
> enter the index number, lets say 0 is entered by the user, and he then  
> asks the user to put a new letter in (letter is a variable), then he  
> wants to change the index of 0 which is the “D” to a “C” (where c was  
> put in by the user).

my\_str = “Dog”  
p “Before: #{my\_str}”

puts “Index?” ; i = Integer(gets)  
puts “letter?”; c = gets.chomp

my\_str[i] = c  
puts “After: #{my\_str}”

-drd
