Saturday, May 9, 2015

Today's RubyKoan comes from the letter "Array" and the numbers ....

Today's Koan comes from the letter "Array" and the numbers ....

An array is an ordered arrangement.
Array of cars: (Audi, Corolla, Tesla)
Array of numbers: ( 1.2, 1.5, 1.9)

class AboutArrayAssignment < Neo::Koan
  def test_non_parallel_assignment
    names = ["John", "Smith"]
    assert_equal __, names
  end

Solution
  def test_non_parallel_assignment
    names = ["John", "Smith"]
    users = ["John", "Smith"]
    assert_equal users, names
  end

What I did here is make a new array with the same names and made that array assert equal to the first array.  As long as the contents of the two arrays match, then I satisfy the call to assert_equal.

Brought to you by KENYACODE. Can you code?

No comments:

Post a Comment