มือใหม่จะมีปัญหากับวิธีการเสมอภาค :
- a == b : ตรวจสอบว่า a และ b เท่ากันหรือไม่ นี่คือประโยชน์สูงสุด
- a.eql? b   : ตรวจสอบด้วยว่า a และ b เท่ากันหรือไม่ แต่บางครั้งก็เข้มงวดกว่า (อาจตรวจสอบว่า a และ b มีประเภทเดียวกันเป็นต้น) ส่วนใหญ่จะใช้ในแฮช
- ก. เท่ากัน? b : ตรวจสอบว่า a และ b เป็นวัตถุเดียวกันหรือไม่ (การตรวจสอบเอกลักษณ์)
- a === b : ใช้ใน case statement (ฉันอ่านว่า " a match b ")
ตัวอย่างเหล่านี้ควรชี้แจง 3 วิธีแรก:
a = b = "joe"
a==b       # true
a.eql? b   # true
a.equal? b # true (a.object_id == b.object_id)
a = "joe"
b = "joe"
a==b       # true
a.eql? b   # true
a.equal? b # false (a.object_id != b.object_id)
a = 1
b = 1.0
a==b       # true
a.eql? b   # false (a.class != b.class)
a.equal? b # false
โปรดทราบว่า  == , eql? และเท่าเทียมกัน? ควรสมมาตรเสมอ: ถ้า a == b แล้ว b == a
สังเกตด้วยว่า==และeql? ทั้งสองถูกนำไปใช้ในคลาส Object เป็นนามแฝงเพื่อให้เท่ากัน? ดังนั้นหากคุณสร้างชั้นเรียนใหม่และต้องการ ==และeql? เพื่อหมายถึงสิ่งอื่นที่ไม่ใช่ตัวตนธรรมดาคุณต้องลบล้างทั้งสองอย่าง ตัวอย่างเช่น:
class Person
    attr_reader name
    def == (rhs)
      rhs.name == self.name  # compare person by their name
    end
    def eql? (rhs)
      self == rhs
    end
    # never override the equal? method!
end
===วิธีการทำงานแตกต่างกัน ก่อนอื่นมันไม่ใช่สมมาตร (a === b ไม่ได้หมายความว่า b === a) อย่างที่บอกคุณสามารถอ่าน a === b เป็น "a match b" นี่คือตัวอย่างบางส่วน:
# === is usually simply an alias for ==
"joe" === "joe"  # true
"joe" === "bob"  # false
# but ranges match any value they include
(1..10) === 5        # true
(1..10) === 19       # false
(1..10) === (1..10)  # false (the range does not include itself)
# arrays just match equal arrays, but they do not match included values!
[1,2,3] === [1,2,3] # true
[1,2,3] === 2       # false
# classes match their instances and instances of derived classes
String === "joe"   # true
String === 1.5     # false (1.5 is not a String)
String === String  # false (the String class is not itself a String)
กรณีคำสั่งจะขึ้นอยู่กับ===วิธีการ:
case a
  when "joe": puts "1"
  when 1.0  : puts "2"
  when (1..10), (15..20): puts "3"
  else puts "4"
end
เทียบเท่ากับสิ่งนี้:
if "joe" === a
  puts "1"
elsif 1.0 === a
  puts "2"
elsif (1..10) === a || (15..20) === a
  puts "3"
else
  puts "4"
end
หากคุณกำหนดคลาสใหม่ที่มีอินสแตนซ์แทนคอนเทนเนอร์หรือช่วงบางประเภท (หากมีบางอย่างเช่นวิธีการinclude?หรือการจับคู่? ) คุณอาจพบว่ามีประโยชน์ในการแทนที่===วิธีการเช่นนี้:
class Subnet
  [...]
  def include? (ip_address_or_subnet)
    [...]
  end
  def === (rhs)
    self.include? rhs
  end
end
case destination_ip
  when white_listed_subnet: puts "the ip belongs to the white-listed subnet"
  when black_listed_subnet: puts "the ip belongs to the black-listed subnet"
  [...]
end