Open In App

Ruby | Vector / method

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Share
Report issue
Report

The / is an inbuilt method in Ruby returns a vector by dividing vector by x

Syntax: vec1 / x

Parameters: The function does not accepts any parameter.

Return Value: It returns a vector by dividing vector by x
.

Example 1:




#Ruby program for / method in Vector
  
#Include matrix
require "matrix"
  
#Initialize the vector
    vec1
    = Vector[1, 5]
  
#Initialize the vector
    x
    = 3
  
#prints the new vector
      puts vec1
      / x


Output:

Vector[0, 1]

Example 2:




#Ruby program for / method in Vector
  
#Include matrix
require "matrix"
  
#Initialize the vector
    vec1
    = Vector[3, 6, 9]
  
#Initialize the vector
    x
    = 3
  
#prints the new vector
      puts vec1
      / x


Output:

Vector[1, 2, 3]

Last Updated : 07 Jan, 2020
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads