+ 4

Replace many letters in a string in ruby gsub method

Hi, maybe someone can help me on this.. I would like to create a code in which I want to replace various letters of a string with the equivalent morse code. I know how to replace one letter, but it won't work for more than one. It's most likely an easy question, but I don't get it. I have used a gsub method in my code to replace the 'a'. Nested gsub? Or is there a better way? https://code.sololearn.com/c773wbMGqEbA/?ref=app

15th Oct 2019, 5:01 PM
Justin Luttkau
Justin Luttkau - avatar
1 ответ
+ 2
I can answer it myself. You have to define a dictionary first and then use this in the gsub method. Pretty Easy. https://code.sololearn.com/cpPoSOLKt1Bw/?ref=app
19th Oct 2019, 9:07 PM
Justin Luttkau
Justin Luttkau - avatar