Ruby | Vector component() function Last Updated : 07 Jan, 2020 Comments Improve Suggest changes Like Article Like Report The component() is an inbuilt method in Ruby returns element at index i in the vector. Indexing starts from zero. Syntax: vec1.component(i) Parameters: The function accepts a single parameter Return Value: It returns element at index i in the vector Example 1: CPP #Ruby program for component() method in Vector #Include matrix require "matrix" #Initialize the vector vec1 = Vector[1, 2] i = 1 #Prints element at index i puts vec1.component(i) Output: 2 Example 2: CPP #Ruby program for component() method in Vector #Include matrix require "matrix" #Initialize the vector vec1 = Vector[1, 2, 3] i = 2 #Prints element at index i puts vec1.component(i) Output: 3 Comment More infoAdvertise with us Next Article Ruby | Vector component() function G gopaldave Follow Improve Article Tags : Ruby Ruby-Methods Ruby Vector-class Similar Reads Ruby | Vector elements() function The elements() is an inbuilt method in Ruby returns the vector which is created using the array Syntax: Vector.elements(array) Parameters: The function accepts a parameter array Return Value: It returns the vector which is created using the array. Example 1: CPP #Ruby program for elements() method i 1 min read Ruby | Vector covector() function The covector() is an inbuilt method in Ruby returns a single-row matrix created using vector Syntax: vec1.covector() Parameters: The function accepts no parameter Return Value: It returns a single-row matrix created using vector Example 1: CPP #Ruby program for covector() method in Vector #Include m 1 min read Ruby | Vector eql?() function The eql?() is an inbuilt method in Ruby returns boolean value true if two vectors are same otherwise false Syntax: vec1.eql?(vec2) Parameters: The function accepts a single vector as parameters Return Value: It returns boolean value true if two vectors are same otherwise false Example 1: Ruby # Ruby 1 min read Ruby | Matrix component() function The component() is an inbuilt method in Ruby returns the element present at the intersection of i-th row and j-th column. Syntax: mat1.component(i, j) Parameters: The function accepts two parameters i and j which signifies the row_number and column_number. Return Value: It returns the element at mat 1 min read Ruby | Matrix column_vectors() function The column_vectors() is an inbuilt method in Ruby returns an array of vectors containing the columns. Syntax: mat1.column_vectors() Parameters: The function does not accepts any parameter. Return Value: It returns an array of vectors containing all the columns. Example 1: Ruby # Ruby program for col 1 min read Like