Related Articles

Related Articles

Ruby | Matrix column_count() function
  • Last Updated : 07 Jan, 2020

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:



filter_none

edit
close

play_arrow

link
brightness_4
code

# Ruby program for column_count() method in Matrix
  
# Include matrix 
require "matrix"
  
# Initialize a matrix 
mat1 =  Matrix[[1, 21], [31, 18]]    
  
# prints the number of columns 
puts  mat1.column_count

chevron_right


Output:

2

Example 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

# Ruby program for column_count() method in Matrix
  
# Include matrix 
require "matrix"
  
# Initialize a matrix 
mat1 =  Matrix[[13, 1, 5], [12, 1, 5], [11, 2, 5]]   
  
# prints the number of columns 
puts  mat1.column_count

chevron_right


Output:

3
My Personal Notes arrow_drop_up
Recommended Articles
Page :