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
相關用法
- Scala Array &()用法及代碼示例
- Scala Array.fill用法及代碼示例
- Scala Array.from用法及代碼示例
- Scala ArrayBufferView.addString用法及代碼示例
- Scala ArrayBufferView.collectFirst用法及代碼示例
- Scala ArrayBufferView.groupMap用法及代碼示例
- Scala ArrayBufferView.sortWith用法及代碼示例
- Scala ArrayBufferView.combinations用法及代碼示例
- Scala ArrayBufferView.permutations用法及代碼示例
- Scala ArrayBufferView.lazyZip用法及代碼示例
- Scala ArrayBufferView.transpose用法及代碼示例
- Scala ArrayBufferView.sizeIs用法及代碼示例
- Scala ArrayBufferView.sliding用法及代碼示例
- Scala ArrayBufferView.tails用法及代碼示例
- Scala ArrayBufferView.groupMapReduce用法及代碼示例
- Scala ArrayBufferView.unzip3用法及代碼示例
- Scala ArrayBufferView.partitionMap用法及代碼示例
- Scala ArrayBufferView.scanRight用法及代碼示例
- Scala ArrayBufferView.unzip用法及代碼示例
- Scala ArrayBufferView.inits用法及代碼示例
- Scala ArrayBufferView.lengthIs用法及代碼示例
- Scala ArrayBufferView.groupBy用法及代碼示例
- Scala ArrayBufferView.sortBy用法及代碼示例
- Scala ArrayBufferView.mkString用法及代碼示例
- Scala ArraySeq.permutations用法及代碼示例
注:本文由純淨天空篩選整理自mayank5326大神的英文原創作品 Ruby | Array ==() method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。