I believe these methods should be renamed. "row_size" is confusing, because it can be intuitively understood as both "number of rows", and "size along a row" (or size of a matrix row). Same goes for "column size". I would like these methods renamed to unambigous, mnemonic names, such as
#number_of_rows alias #height
#number_of_columns alias #width
I do not insist on the above names. They are just examples of unambigous, mnemonic names. But I insist that "row_size" and "column_size" method names impress me as ambiguous.
@Eregon (Benoit Daloze): #m and #n? Maybe as aliases, but I think that one-character methods should be generally left to daring users. Perhaps #m_size and #n_size.
@Marc-Andre: This is what they call conundrum. #number_of_rows is clear, but almost as long as #each_with_object. #row_count is shorter, but less mnemonic. #nb_rows and such is even less mnemonic. #height / #width is unambiguous, but slightly boorish with respect to mathematicians. Some recommend that methods should be named only with full-length (unabbreviated) English words, but on the other hand, when writing core or stdlib, one is allowed to trade brevity for mnemonism, as seen eg. in "attr_reader". For that case, #no_of_rows / #no_of_columns can be considered. Additional possibility is having a method named eg. #dimensions returning [m, n] for m x n matrix.
This issue was solved with changeset r38300.
Boris, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.
lib/matrix: alias {row|column}_size to {row|column}_count and use the latter.
[Bug #7369] [ruby-core:49409]