当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


Scala Array ==()用法及代码示例


Array#==() 是一个 Array 类方法,用于执行两个数组之间的比较。它检查两个数组是否相等。

用法:Array.==()

参数:用于比较的数组

Return: true :如果数组相等
false:如果数组不相等

示例#1:


# Ruby code for ==() method 
# checking equality 
   
# differencing arrays 
a = [18, 22, 33, 4, 5, 6] 
   
# differencing arrays 
b = [18, 22, 33, 4, 5, 6] 
   
# differencing arrays 
c = [18, 22, 33, 40, 50, 6] 
   
# checking array equality 
puts "comparison : #{a == b}\n\n"
   
# checking array equality 
puts "comparison : #{a == c}\n\n"
   
# checking array equality 
puts "comparison : #{b == c}\n\n"

输出:

comparison : true

comparison : false

comparison : false

示例#2:


# Ruby code for ==() method 
# checking equality 
   
# differencing arrays 
a = ["abc", "xyz", "dog"] 
   
# differencing arrays 
b = ["cat", "cat", "dog"] 
   
# differencing arrays 
c = ["cat", "cat", "dog"] 
   
# checking array equality 
puts "comparison : #{a == b}\n\n"
   
# checking array equality 
puts "comparison : #{a == c}\n\n"
   
# checking array equality 
puts "comparison : #{b == c}\n\n"

输出:

comparison : false

comparison : false

comparison : true


相关用法


注:本文由纯净天空筛选整理自mayank5326大神的英文原创作品 Ruby | Array ==() method。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。