Error: constant false is not an lvalue

Ary Borenszweig ary at esperanto.org.ar
Sat Aug 29 21:24:17 PDT 2009


Steven Schveighoffer escribió:
> On Sat, 29 Aug 2009 20:15:55 -0400, Ellery Newcomer 
> <ellery-newcomer at utulsa.edu> wrote:
> 
>> void blah(out bool a = false){
>>  // blah blah blah
>> }
>>
>> compile time use of blah results in error.
>>
>> Am I doing anything wrong?
> 
> out implies a reference.  You can't have a reference to a manifest 
> constant like that.
> 
> If you want to ensure a is false at the beginning of the function do:
> 
> void blah(out bool a)
> {
>   a = false;
>   // blah blah blah
> }
> 
> -Steve

Or just not write it, because "out" automatically initializes the value 
of the variable to it's default one, in the case of bool it's false.


More information about the Digitalmars-d-learn mailing list