Challenge Part 1:
A fun exercise which is always good Ruby practice is to re-implement an existing Ruby method. This morning, we are going to be re-implementing #reverse
.
Create a file in a folder using touch reverse.rb
In that file, write a method that will take a string as an argument and return that string reversed. Something like this:
def my_reverse(string)
# your code goes here
end
puts my_reverse("hello")
Then running the file by using a ruby reverse.rb
should output to the screen, olleh
Testing is not required for this challenge. Think about some edge cases, and make sure that spaces also work.
Challenge Part 2:
Re-implement #flatten