-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 > Daniel Berger wrote: >> 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, too, run into this a lot and wish attr_accessor :foo? "just worked." On Sep 19, 2005, at 5:14 PM, James Britt wrote: > 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 > [...] > And should not foo=( val ) also enforce that @foo only takes on > boolean values? The ? suffix indicates that we should use the method as a predicate. Thankfully, Ruby does not require values in predicates to evaluate to an explicit true or false. Perhaps take a look at ML ;) Given that attr_* are here to wrap a common idiom for our convenience, it is natural that they should understand the ? suffix if it is in widespread use. Pragmatically yours, jeremy -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2 (Darwin) iD8DBQFDL1ffAQHALep9HFYRAisUAKCn+hPmTn2p99vFOAf0DhPEZ317EwCfUS0D Y+2EEs/eGhOEwXHhhBkEp3Y= =oyc1 -----END PGP SIGNATURE-----