Skip to content

Instantly share code, notes, and snippets.

@FsDevNinja
Created November 1, 2016 14:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FsDevNinja/dbace853ed558860e3bd72967a6c00be to your computer and use it in GitHub Desktop.
Save FsDevNinja/dbace853ed558860e3bd72967a6c00be to your computer and use it in GitHub Desktop.
Reverse a string in ruby without using .reverse
module StringReverser
def self.reverse(input)
return nil if input == nil
output = []
input.split("").each_with_index do |n,i|
output << input[-i-1]
end
output.join("").to_s
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment