From: Daniel Berger Date: 2007-12-14T20:36:19+09:00 Subject: Re: attr_accessor for question methods (?) Charles Oliver Nutter wrote: > Trans wrote: >> Like to make a small suggestion for 1.9. It would be great if we could >> do: >> >> attr_accessor :foo? >> >> With the effect of: >> >> def foo? >> @foo >> end >> >> def foo=(x) >> @foo=x >> end >> >> This is much nice then having to define one attribute plus a >> supplemental "?" method. attr_reader :foo? would work too, of course. >> While it would be rather meaningless for attr_writer, it could work in >> any case --really no need to raise an error. >> >> A minor detail, but one that would be convenient to have. > > Perhaps an additional method would be the way to do it? > > question_accessor > predicate_accessor > pred_accessor > boolean_accessor > bool_accessor -1 No, because then you'll need yet another accessor method for bang methods, too. Dan