ProgFu

programming tips & tricks

Dec 22

Walk the Path to Ruby Enlightenment

As Ruby is gaining popularity, many new people come to learn it. Even though there are numerous numbers of books for the topics, many programmers prefer to learn by example.

Not everyone has the time to buy a thick book full of examples and just start reading it. Then you have to rewrite the examples from the book to try them yourself, which is pain in sometimes pain in the ass, as books contain typos and other mistakes.

There’s another way to learn Ruby though, and that is Ruby Koans.

Kōan is a fundamental part of the history and lore of Zen Buddhism. It consists of a story, dialogue, question or statement, the meaning of which cannot be understood by rational thinking buy may be accessible through intuition.

Ruby Koans are basically very small examples, which teach you little things about the Ruby language. They are written in form of failing tests which need to be corrected.

First Koan will teach you about the assert method

All you need to do is just make the test pass. Now you might say yeah but that is silly, everyone knows I should put in ‘true’.

While that might be right, consider little more complex Koan

This is perfect example to teach you about the difference between (1..5) and (1...5) Range in Ruby. And there is much more.

Ruby Koans are also created in the spirit of Test Driven Development, as they encourage moving forward by little steps and running your test suite every time you change the code.

Even if you’re experienced Ruby programmer, you can learn something new and cool about the Ruby language. Don’t hesitate and give Ruby Koans a try!


Page 1 of 1