Skip to content

Files

Latest commit

 

History

History
23 lines (15 loc) · 478 Bytes

Style-MultipleComparison.md

File metadata and controls

23 lines (15 loc) · 478 Bytes

Pattern: Comparing variable with multiple items

Issue: -

Description

This rule checks against comparing a variable with multiple items, where Array#include? could be used instead to avoid code repetition.

Examples

# bad
a = 'a'
foo if a == 'a' || a == 'b' || a == 'c'

# good
a = 'a'
foo if ['a', 'b', 'c'].include?(a)

Further Reading