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 program for row_size() method in Matrix # Include matrix require "matrix"
# Initialize a matrix mat1 = Matrix[[ 6 , 432 ], [ 54 , 323 ]]
# Prints the number of rows puts mat1.row_size() |
Output:
2
Example 2:
# Ruby program for row_size() 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_size() |
Output:
3