Reverse the Letters in a String Without Using the Reverse Method in Ruby
In this coding exercise you’ll re-create the reverse method in Ruby. You are required to build a method that reverses the characters in a string and returns the reversed values.
Build a method that reverses the characters in a string without using the
You will need to perform monkey patching and open up the
String class in Ruby. From there create a method called
alt_reversethat reverses the characters in a string without calling the
reverse method provided by Ruby.
"Hi there".alt_reverse # "ereht iH"
Real World Usage
In a real life program you would call the
reverse method directly, so this method isn’t necessary. However in this exercise you will:
- Learn three important operations that can be performed on the
Stringclass in Ruby.
- Implement monkey patching
Additionally, this is a common Ruby coding interview question that tests an applicant’s knowledge of the
Can be found on the solutions branch on github.