📜  红宝石 |向量 == 方法

📅  最后修改于: 2022-05-13 01:55:27.451000             🧑  作者: Mango

红宝石 |向量 == 方法

==是 Ruby 中的内置方法,如果两个向量具有相同顺序的相同元素,则返回 true,否则返回 false

示例 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

输出

true

示例 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

输出

false