[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: multi dim array?

Gavin Kistner

10/20/2006 10:19:00 PM

From: Gijs Nijholt
> def translate_to_braille(msg)

I think you want the String#tr method. It replaces each character in a
source string with its corresponding character in a replacment string:

normal_alphabet = "abcdefghijklmnopqrstuvwxyz"
rot13_alphabet = "nopqrstuvwxyzabcdefghijklm"

msg = "hello world!"
puts msg.tr( normal_alphabet, rot13_alphabet)
#=> uryyb jbeyq!