📜  红宝石 |矩阵 eql?函数

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

红宝石 |矩阵 eql?函数

情商?是 Ruby 中的一个内置方法,返回一个布尔值。如果两个矩阵相等,则返回 true,否则返回 false。

示例 1

Ruby
# Ruby program for eql? method in Matrix
  
# Include matrix
require "matrix"
  
# Initialize a matrix
mat1 = Matrix[[1, 21], [31, 18]]
mat2 = Matrix[[1, 21], [31, 18]]  
  
# Prints if both are equal or not
puts  mat1.eql?(mat2)


Ruby
# Ruby program for eql? method in Matrix
  
# Include matrix
require "matrix"
 
# Initializes the matrix
mat1 = Matrix[[1, 21], [31, 18]]
mat2 = Matrix[[1, 16], [31, 28]]
  
# Prints if both are equal or not
puts  mat1.eql?(mat2)


输出

true

示例 2

红宝石

# Ruby program for eql? method in Matrix
  
# Include matrix
require "matrix"
 
# Initializes the matrix
mat1 = Matrix[[1, 21], [31, 18]]
mat2 = Matrix[[1, 16], [31, 28]]
  
# Prints if both are equal or not
puts  mat1.eql?(mat2)

输出

false