Skip to content

Instantly share code, notes, and snippets.

@micedreams
Created November 12, 2023 11:26
Show Gist options
  • Save micedreams/6108434cf8336ed6c12b839f7ade5d71 to your computer and use it in GitHub Desktop.
Save micedreams/6108434cf8336ed6c12b839f7ade5d71 to your computer and use it in GitHub Desktop.
reversewords.rb
puts"enter string to get reverse words"
line=gets
def reverse string
arr = string.split /\b/
new_arr = arr.collect {|a| a.reverse}
new_arr.join
end
reverse=reverse(line)
puts "reverse worded string= #{reverse}"
puts"\n End of Program :)\n\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment