Skip to content

Instantly share code, notes, and snippets.

@ph3nx
Created January 18, 2014 18:51
Show Gist options
  • Save ph3nx/8494566 to your computer and use it in GitHub Desktop.
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”.
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