Ruby | Matrix column_size() function
Last Updated :
07 Jan, 2020
The column_size() is an inbuilt method in Ruby returns the number of columns in a matrix.
Syntax: mat1.column_size()
Parameters: The function does not accepts any parameter.
Return Value: It returns the number of columns in a matrix.
Example 1:
require "matrix"
mat1 = Matrix[[ 1 , 21 ], [ 31 , 18 ]]
puts mat1.column_size
|
Output:
2
Example 2:
require "matrix"
mat1 = Matrix[[ 13 , 1 , 5 ], [ 12 , 1 , 5 ], [ 11 , 2 , 5 ]]
puts mat1.column_size
|
Output:
3
Share your thoughts in the comments
Please Login to comment...