Skip to content

Files

Latest commit

 

History

History
25 lines (17 loc) · 477 Bytes

Lint-DisjunctiveAssignmentInConstructor.md

File metadata and controls

25 lines (17 loc) · 477 Bytes

Pattern: Disjunctive assignment in constructor

Issue: -

Description

In ruby, an instance variable is nil until a value is assigned, so the disjunction is unnecessary. A plain assignment has the same effect.

Examples

# bad
def initialize
  @x ||= 1
end

# good
def initialize
  @x = 1
end

Further Reading