Open In App

Ruby | Vector eql?() function

Improve
Improve
Like Article
Like
Save
Share
Report

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 program for eql?() method in Vector
     
# Include matrix 
require "matrix"
     
# Initialize the vector
vec1 = Vector[1, 2, 3]
vec2 = Vector[1, 2, 3
    
# Checks if two vectors are same or not
puts vec1.eql?(vec2)


Output:

true

Example 2:




# Ruby program for eql?() method in Vector
     
# Include matrix 
require "matrix"
     
# Initialize the vector
vec1 = Vector[1, 2, 3]
vec2 = Vector[1, 1, 3
    
# Checks if two vectors are same or not
puts vec1.eql?(vec2)


Output:

false

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