Open In App

Ruby | Matrix row_count() function

Last Updated : 07 Jan, 2020
Comments
Improve
Suggest changes
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

Next Article

Similar Reads