Project

General

Profile

Feature #16817

attr_predicate or attr_query or attr_something for ? methods

Added by robotdana (Dana Sherson) 7 months ago.

Status:
Open
Priority:
Normal
Assignee:
-
Target version:
-
[ruby-core:98064]

Description

I would like attr_predicate like attr_reader etc.

attr_predicate :cat would define a method named :cat? that returned the value for ivar @cat.

I would like this because i find myself writing this:

def cat?
  @cat
end

which is fine once, but becomes tedious with many attributes

Another possibility is allowing attr_reader :cat? to define a method that returns the value for ivar @cat. currently it raises NameError (invalid attribute namecat?')`

Thank you

No data to display

Also available in: Atom PDF