I have never heard of the tap method but am glad I have made the discovery. I planned to use it in my code at work, but have not had the opportunity yet. I find lately I have tried to force many new concepts in my code, but have yet been able to.
Its probably better not to force them. I love the idea of the <=> operator but have not used it once in a real life experience, even in code quizzes. I will probably used the {}.tap method sooner and actually tried it out for the first time yesterday, but ended up taking it out in a refactor.
Check out this blog on the tap.{} method.
I am finding out that there is a right way to Ruby and wish I read Eloquent Ruby a lot earlier. I spent too much time not reading books and going through basics of Ruby. I highly recommend every new Rubyist to read Eloquent Ruby. It is a great guide into Ruby and explains a lot of questions about when to how to write Ruby with best practices.
No comments:
Post a Comment