Wednesday, May 6, 2015

RubyKoan: Test_Assert_Truth

I am going through the Ruby Koans. Each day or so, I will post one Koan and explain how I got to the answer. I hope this is helpful to the many programmers out there like me who don't just want an answer but want to understand how to understand the answer. 

To get set up with Ruby Koans, go to Ruby Koans here is the URL: http://rubykoans.com

# We shall contemplate truth by testing reality, via asserts.
def test_assert_truth
assert __ # This should be true
end

Solution
def test_assert_truth
assert true # This should be true
end

My thought process started with the note (# This should be true).
Then I read the word asserts. Assert means to state a fact or belief confidently and forcefully.
It was asking for the function to assert true so I put true in the blank. It therefore read Assert true.
Looking at it now I could have put a statement that equals to true and that should also pass the test.

What do you think?

Brought to you by KENYACODE.  Can you code?

No comments:

Post a Comment