Boolean prefix (ARCH6007)
هذا المحتوى غير متوفر بلغتك بعد.
Key ruby.naming.predicate-question-mark · Severity info · Category naming
Methods that return a boolean should end with a question mark in Ruby (active?), which makes conditionals read naturally. Predicate methods without the interrogative form make conditions read poorly.
Incorrect
Section titled “Incorrect”class Account def active @status == :active endendCorrect
Section titled “Correct”class Account def active? @status == :active endendEnd boolean methods with a question mark (active?); an is_/has_ prefix is also acceptable for predicates.