From: Daniel Berger Date: 2005-09-20T12:55:30+09:00 Subject: Re: proposed attr writer patch --- James Britt wrote: > Daniel Berger wrote: > > --- Mathieu Bouchard wrote: > > > > > >>On Sun, 18 Sep 2005, Christian Neukirchen wrote: > >> > >>>James Britt writes: > >>> > >>>>Daniel Berger wrote: > >>> > >>>IMHO, `foo?' makes sense (if @foo is meant to be > >> > >>boolean), > >> > >>IMHO, FOO$ also makes sense, if it is meant to be > a > >>string. > > > > > > Oh, let's not go over the top, shall we? > > > > To answer James' earlier question, there wouldn't > be > > much point to using this patch for bang methods, > but > > it would be handy for the boolean methods. > > > > Instead of: > > > > attr_writer :foo > > def foo? > > @foo > > end > > > > I could just do: > > > > attr_accessor :foo? > > I see. > > But does this, then, enforce the booleanitude of > "foo?"? > > In other words, if you're going to have a method > foo?, should it not be > something like > > def foo? > @foo ? true : false > end > > And should not foo=( val ) also enforce that @foo > only takes on boolean > values? Why should it? The use of "?" and "!" in method names is just a convention. There's no enforcement when you write one of these methods long-hand, so there shouldn't be any enforcement when using a shortcut method, either. Regards, Dan __________________________________ Yahoo! Mail - PC Magazine Editors' Choice 2005 http://mail.yahoo.com