Skip to content

Files

Latest commit

 

History

History
25 lines (16 loc) · 567 Bytes

Lint-IdentityComparison.md

File metadata and controls

25 lines (16 loc) · 567 Bytes

Pattern: Use of == when comparing object_id

Issue: -

Description

Prefer equal? over == when comparing object_id.

Object#equal? is provided to compare objects for identity, and in contrast Object#== is provided for the purpose of doing value comparison.

Examples

# bad
foo.object_id == bar.object_id

# good
foo.equal?(bar)

Further Reading