Skip to content

Instantly share code, notes, and snippets.

@surrealdetective
Created June 18, 2013 13:31
Show Gist options
  • Save surrealdetective/5805374 to your computer and use it in GitHub Desktop.
Save surrealdetective/5805374 to your computer and use it in GitHub Desktop.
reverse the word
def reverse_each_word(sentence)
print sentence.split.each {|word| word.reverse!}.join(" ")
end
reverse_each_word("Hello there, and how are you?")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment