Ad
  • Custom User Avatar

    This honestly should be clarified in the instructions. It's been asked about multiple times in the discussion and threw me off when I read over the instructions too.

  • Custom User Avatar

    It's described in the docs at http://ruby-doc.org/core-2.2.3/String.html#method-i-gsub.

    If the second argument is a Hash, and the matched text is one of its keys, the corresponding value is the replacement string.

  • Custom User Avatar

    Maybe it's becuase I'm tired, but I don't understand how this function returns nil for the matrix [[1,2,3], [4,5,6]].

    In the first run, we get cen = [4,5,6] (2/2 = 1), which is an array, and so the program proceeds to recursively call center, now with the argument [4,5,6]. This time, we get cen = 5 (since (3/2 = 1)). This is not an array, and so the cen if mat.size.odd? statement executes. The size of [4,5,6] is 3, which is an odd number. So I don't understand how this returns nil. Someone please explain :)