Week 2 Challenge at Makers Academy
This challenge demonstrates use of Ruby and Rspec.
Tasks
- Rewrite using Iterators
- Rewrite using Recursion
In a preliminary review of this project with a coach, I was told that I have approached this problem incorrectly. I should have re-written the method by breaking it down in to several other smaller methods, like I would normally do in larger projects. I had interpreted the task as a test to make inject as one singular method.
Since the method works correctly in it's current state, I have chosen to leave it as it is for now, as a testament to the time it took to create it!
If I were to refactor it, I would start by taking out the initial states into multiple methods, i.e. when the arg is a symbol, when the arg is an initial value and a symbol, etc. These setup sections are the more complicated sections of the code, and are currently not very readable.
Given some time, I will try to do this re-write in an OOP style.