Skip to content

Instantly share code, notes, and snippets.

@mikedao
Last active June 3, 2020 15:47
Show Gist options
  • Save mikedao/c7f34b3487603e8dc107e998899a6899 to your computer and use it in GitHub Desktop.
Save mikedao/c7f34b3487603e8dc107e998899a6899 to your computer and use it in GitHub Desktop.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment