Skip to content

Instantly share code, notes, and snippets.

@LevitatingBusinessMan
Created June 27, 2019 21:50
Show Gist options
  • Select an option

  • Save LevitatingBusinessMan/21cf6f3c465c8b10405ab879f8f444f5 to your computer and use it in GitHub Desktop.

Select an option

Save LevitatingBusinessMan/21cf6f3c465c8b10405ab879f8f444f5 to your computer and use it in GitHub Desktop.
PigLatin in Ruby
def pigLatin(input = "Pig Latin")
input = input.downcase
result = []
for word in input.split(" ") do
#First character is a vowel
if ["a", "e", "i", "o", "u"].include?(word[0])
result.push word + "ay"
#First character isn't a vowel
else
result.push word[1..-1] + word[0] + "ay"
end
end
return result.join " "
end
p pigLatin ARGV.join " "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment