Learn Ruby (v1.8.7) With the Edgecase Ruby Koans Online

Bahasa Melayu English Tiếng Việt

Ruby Koans Online

The Ruby Koans are a great way to learn about the Ruby language. This Ruby Koans Online is an abridged version of the Koans in the convenience of a browser.

However, if this is your first time through the Koans, we recommend you read the introduction below to find out how the Koans work.

Start the Koans >>

The Koans World

The koans are broken out into areas covering such topics as hashes, modules and classes. Each of these are presented on their own page. Each koan builds up your knowledge of Ruby and builds upon itself.

The Path to Enlightenment

Each page consists of a number of tests that you have to complete and any information you might require to help you make those test pass. You can run the tests by clicking the Meditate button at any time or by pressing the Enter key when filling in any of the tests.

Red, Green, Refactor

In test-driven development (TDD) the mantra has always been

  1. red : write a failing test and run it,
  2. green : write just enough code to make the test pass, and
  3. refactor : look at the code to see if you can make it any better.

With the Ruby Koans Online,

  1. the tests will start in the failing state (background is red)
  2. type what you expect the result(s) to be in the input box(es) provided to make the test pass ( background becomes green)
  3. then take a moment to reflect upon the test to see what it is teaching you and, if required, improve the code to better communicate its intent (refactor)

The happy path

For example, type true in the input box below and then click the Meditate button or hit Enter to turn the box green.

# True should be true.
# <false> expected but was <true>.
  def test_example
    assert_equal  , true

Straying from the path

If the results were not what you expected, the Koans will guide you back to the enlightened path with a hint.
Type false in the box below to see the hint displayed.

# True should be true.
# <false> expected but was <true>.
  def test_example
    assert_equal  , true

Wait, but it said it expected false! What gives!?

The wording comes from the TestUnit framework.
In TDD you will write a test with an expectation of how you want the code to behave and then write the actual code to make that test pass.

This might seem confusing in the case of the Ruby Koans, where most of the test is usually written for you.
In Koans you are providing what your expectation is, so the test framework reports your expectations vs actual results.

Known Issues

If you encounter any other issues whilst using the Ruby Koans Online, please contact us using the Contact button at the top right of the window.

Thanks, the Ruby Koans Online Team

Start the Koans >>

Thanks for trying the Ruby Koans Online. We hope you're having fun.


Submit issues to the Github project.


Blog about it or send us an email.

Get More

Download the official Ruby Koans and get the full experience.