Ruby | Matrix row() function Last Updated : 12 Jul, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report 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 in the num row. Example 1: Ruby # Ruby program for row() method in Matrix # Include matrix require "matrix" # Initialize a matrix mat1 = Matrix[[6, 432], [54, 323]] # Prints the 0th row puts mat1.row(0) Output: Vector[6, 432] Example 2: Ruby # Ruby program for row() method in Matrix # Include matrix require "matrix" # Initialize a matrix mat1 = Matrix[[1, 1, 1],[2, 2, 2],[3, 5, 6]] # Prints the 1sr row puts mat1.row(1) Output: Vector[2, 2, 2] Comment More infoAdvertise with us Next Article Ruby | Matrix rank() function G gopaldave Follow Improve Article Tags : Ruby Ruby-Methods Ruby Matrix-class Similar Reads Ruby | Matrix round() function The round() is an inbuilt method in Ruby returns all the values of the matrix rounded to the given number of digits after decimal point. In case no parameter is passed, then 0 is assumed to be the default value. Syntax: mat1.round(num) Parameters: The function takes a non-mandatory parameter num to 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 Ruby | Matrix rank() function The rank() is an inbuilt method in Ruby returns the rank of the given matrix. The float values can yield enormous results due to float precision Syntax: mat1.rank() Parameters: The function does not accepts any parameter. Return Value: It returns the rank of the current matrix. Example 1: CPP #Ruby 1 min read Ruby | Matrix real?() function The real?() is an inbuilt method in Ruby returns a boolean value. It returns true if all values in the matrix are real, else it returns false. Syntax: mat1.real?() Parameters: The function needs the matrix which is to be checked for real values Return Value: It returns true if it all values are real 1 min read Ruby | Matrix real() function The real() is an inbuilt method in Ruby returns a matrix with only real part in it. The other index are assigned to zero. Syntax: mat1.real() Parameters: The function does not takes any parameter. Return Value: It returns a matrix with only real part. Example 1: CPP #Ruby program for real() method i 1 min read Ruby | Matrix row_count() function 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 M 1 min read Like