Open In App

Ruby | Vector == method

Improve
Improve
Like Article
Like
Save
Share
Report

The == is an inbuilt method in Ruby returns true if the two vectors have the same elements in the same order otherwise false

Syntax: vec1 == vec2

Parameters: The function does not accepts any parameter.

Return Value: It returns true if the two vectors have the same elements in the same order otherwise false.

Example 1:




#Ruby program for == method in Vector
  
#Include matrix
require "matrix"
  
#Initialize the vectors
    vec1
    = Vector[1, 2] vec2 = Vector[1, 2]
  
#prints the new vector
                          puts vec1
                          == vec2


Output:

true

Example 2:




#Ruby program for == method in Vector
  
#Include matrix
require "matrix"
  
#Initialize the vectors
    vec1
    = [ 1, 2 ] vec2 = [ 2, 1 ]
  
#prints the new vector
                      puts vec1
                      == vec2


Output:

false

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