Ruby | Matrix row_count() function Last Updated : 12 Jul, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report The row_count() is an inbuilt method in Ruby returns the number of rows in the given matrix. Syntax: mat1.row_count() Parameters: The function does not takes any mandatory parameter. Return Value: It returns the number of rows in the matrix. Example 1: Ruby # Ruby program for row_count() method in Matrix # Include matrix require "matrix" # Initialize a matrix mat1 = Matrix[[6, 432], [54, 323]] # Prints the number of rows puts mat1.row_count() Output: 2 Example 2: Ruby # Ruby program for row_count() method in Matrix # Include matrix require "matrix" # Initialize a matrix mat1 = Matrix[[1, 1, 1],[2, 2, 2],[3, 5, 6]] # Prints the number of rows puts mat1.row_count() Output: 3 Comment More infoAdvertise with us Next Article Ruby | Matrix component() function G gopaldave Follow Improve Article Tags : Ruby Ruby-Methods Ruby Matrix-class Similar Reads Ruby | Matrix row() function The row() is an inbuilt method in Ruby returns a vector that contains all the elements in the given row-number. Syntax: mat1.row(num) Parameters: The function takes a mandatory parameter row, whose elements are to be returned in a vector. Return Value: It returns a vector containing all the elements 1 min read Ruby | Matrix column() function The column() is an inbuilt method in Ruby returns a vector that has all the elements in the column number col_num. Syntax: mat1.column(col_num) Parameters: The function accepts a parameter col_num which is the column number. Return Value: It returns a vector which has all the elements of column col_ 1 min read Ruby | Matrix column_count() function The column_count() is an inbuilt method in Ruby returns the number of columns in a matrix. Syntax: mat1.column_count() Parameters: The function does not accepts any parameter. Return Value: It returns the number of columns in a matrix. Example 1: Ruby # Ruby program for column_count() method in Matr 1 min read Ruby | Matrix collect() function The collect() is an inbuilt method in Ruby returns the new matrix after performing the operation that is given in the block. Syntax: mat1.collect{|el| operation} Parameters: The function has the parameter as a block which is the operation which is performed on all elements. Return Value: It returns 1 min read Ruby | Matrix component() function The component() is an inbuilt method in Ruby returns the element present at the intersection of i-th row and j-th column. Syntax: mat1.component(i, j) Parameters: The function accepts two parameters i and j which signifies the row_number and column_number. Return Value: It returns the element at mat 1 min read Ruby | Matrix row_size() function The row_size() is an inbuilt method in Ruby returns the number of rows in the given matrix. Syntax: mat1.row_size() Parameters: The function does not takes any mandatory parameter. Return Value: It returns the number of rows in the matrix. Example 1: Ruby # Ruby program for row_size() method in Matr 1 min read Like