Skip to content

Instantly share code, notes, and snippets.

@kayline
Created March 21, 2013 03:53
Show Gist options
  • Save kayline/5210561 to your computer and use it in GitHub Desktop.
Save kayline/5210561 to your computer and use it in GitHub Desktop.
Reverse words. Seems to work but the Rspec fails
def reverse_words(str)
array = []
result = ""
str.each_line(" ") { |s| array.push(s.reverse)}
array.each do |i|
result = result + i +" "
end
result = result.chop.lstrip
puts result
return result
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment