Ir al contenido

Boolean prefix (ARCH6007)

Esta página aún no está disponible en tu idioma.

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.

class Account
def active
@status == :active
end
end
class Account
def active?
@status == :active
end
end

End boolean methods with a question mark (active?); an is_/has_ prefix is also acceptable for predicates.