Skip to content
Related Articles

Related Articles

Improve Article

Ruby | Vector elements() function

  • Last Updated : 07 Jan, 2020

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:






#Ruby program for elements() method in Vector
  
#Include matrix
require "matrix"
  
#Initialize the array
    arr
    = [ 1, 2, 3 ]
  
#Initialize the vector
    vec1
    = Vector.elements(arr)
  
#prints the new vector
          puts vec1

Output:

Vector[1, 2, 3]

Example 2:




#Ruby program for elements() method in Vector
  
#Include matrix
require "matrix"
  
#Initialize the vector
    vec1
    = Vector.elements([ 1, 2, 3 ])
  
#prints the new vector
          puts vec1

Output:

Vector[1, 2, 3]
My Personal Notes arrow_drop_up
Recommended Articles
Page :