Josh told me today that one
way to see if someone is any good at Ruby is to have them implement
the *ect methods in terms of inject. This isn’t a fool-proof method,
and I’m also not concerned about it’s
as much as I am simply interested in how to do it. Most importantly,
do I meet Josh’s standards?
(As Nick pointed out,
anyone who’s spent more than 5 minutes functional programming would
laugh at this. I’m a newbie.)
Before I show my code, I’m going to give you the opportunity to go try
it for yourself. Write custom #detect, #select, #reject, and #collect
methods in terms of Enumerable#inject.
Here’s a little RSpec example that will let you automatically verify
And now for my implementation:
How did you do it?
You know that folder you’ve got filled with coding projects that never made it off the ground?
- code snippets that could become libraries, with a few tests
- libraries that could become gems, with some new documentation
- gems that could become side projects, with a bit of refactoring
- side projects that could become products, with the right game plan
You start each project with the best intentions, even big plans for some of them… but then life gets in the way, and you focus your attention on more important things. Then when you get some free time you dream up another project, and the cycle repeats itself.
You know that you can ship – you get all kinds of other projects out the door at work. Why do your open source ideas collect dust and regret?
The rules you apply to get stuff done at work don’t apply to your hobby projects. If you take the objective-driven approach you use in your work and try to use it on your hobby projects, you will continue to fall short of your goals – and keep piling on the guilt.
You can break the cycle, by launching one of your open source project ideas. You can push the spiral upward, by getting one project out the door and moving on to the next one.
You just need to learn a few skills and techniques that will help you dig in to your project graveyard and bring your projects to life.
Get Hack Your Open Source Project for FREE and you will: