John
John

Reputation: 443

Unfamiliar syntax in a method

So I'm working through the Koans ruby exercises and am unfamiliar with the syntax in the block for this method. Can somebody explain to me what is described in here starting with the 2nd line? Thanks !!!

    def test_nil_is_an_object
        assert_equal true, nil.is_a?(Object), "Unlike NULL in other languages"
    end

Upvotes: 1

Views: 51

Answers (1)

dredozubov
dredozubov

Reputation: 725

You can omit parentheses in ruby, so it is basically an assert_equal call. It can be rewritten as following:

assert_equal(true, nil.is_a?(Object), "Unlike NULL in other languages")

Two forms are equivalent.

Upvotes: 3

Related Questions