Convert Integers to Strings

  • Thread starter Gary Christopher
  • Start date
G

Gary Christopher

Howdy,

New to Ruby and looking for some help.
I would like to prompt the user for input String of single [0 - 9 incl]
digits e.g 57
and convert these to word format and store as a single string e.g
fiveseven

What way is best to go about doing this.

Should I create a hash of {1 => "one".....} and then iterate through the
input, swapping digits that match a key with the key's value.

Thanks a lot
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top