Created
January 18, 2014 18:51
-
-
Save ph3nx/8494566 to your computer and use it in GitHub Desktop.
Ruby program with functions that translate english to Pig Latin and back to English. English is translated to Pig Latin by taking the first letter of every word, moving it to the end of the word and adding ‘ay’. “The quick brown fox” becomes “Hetay uickqay rownbay oxfay”.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def english_2_pig_latin string | |
string.split(/ /).each do |word| | |
word << word[0] << "ay " | |
print word[1..word.length] | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment