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?
Don’t waterfall your way to burnout and debt!
Take tiny steps and upgrade to a programming job you love! <3 <3
The standard advice for learning Ruby on Rails catches you in an infinite loop of confusion…
Don’t condemn your aspirations to the dustbin of regrets!
Change your world in real-time: learn Ruby programming in an Agile community.