Open In App

Ruby | Vector elements() function

Last Updated : 07 Jan, 2020
Comments
Improve
Suggest changes
Like Article
Like
Report
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 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: CPP
#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]

Next Article

Similar Reads