Skip to content

Instantly share code, notes, and snippets.

@siciliana
Created August 29, 2013 00:17
Show Gist options
  • Select an option

  • Save siciliana/6372970 to your computer and use it in GitHub Desktop.

Select an option

Save siciliana/6372970 to your computer and use it in GitHub Desktop.
Pig latin redux - verbally reviewed/refactored https://gist.github.com/scottmascio2115/44ff65d16597b1c50753
# Solution for Challenge: Pig-latin. Started 2013-08-28T23:49:41+00:00
def pig_latin
puts "Enter a word."
word = gets.chomp
vowels = ["a", "e", "i", "o", "u", "A", "E", "I", "O", "U"]
first_letter = word.chr
if vowels.include?(first_letter ) == true
return word
end
index_of_vowel = word.index(/[aeiouAEIOU]/)
sliced = word.slice!(0, index_of_vowel)
word + sliced + 'ay'
end
p pig_latin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment