From: Todd Benson Date: 2008-02-17T19:16:21+09:00 Subject: Re: Use of ? in variable names On Feb 16, 2008 12:04 PM, Michael Brooks wrote: > Hello everyone: > > Why can't I name boolean variables with a "?" on the end? The "?" can > be used on the end of methods but not variable. Here is an example: > > # This naming convention works with "?" > def boolean_method? > return true > end > puts boolean_method? > > # This naming convention doesn't works with "?" > boolean_variable? = true > puts boolean_variable? > > The question mark would make the intention of the variable obvious, just > like it helps the method name. > > So why isn't this allowed? Did I miss something? I suppose because any object is true and the following wouldn't make sense... boolean_variable? = "false" You want to 'type' a variable (the syntax defines its purpose), which goes against the general grain of Ruby. Todd