Skip to content

Instantly share code, notes, and snippets.

@abrahamsangha
Created May 9, 2013 12:51
Show Gist options
  • Save abrahamsangha/5547269 to your computer and use it in GitHub Desktop.
Save abrahamsangha/5547269 to your computer and use it in GitHub Desktop.
a method reverse_words which takes a sentence as a string and reverse each word in it.
def reverse_words(str)
str.split.each { |word| word.reverse!}.join(' ')
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment