Why do "const inout" and "const inout shared" exist?

Walter Bright via Digitalmars-d digitalmars-d at puremagic.com
Sun Jul 2 11:30:08 PDT 2017


On 7/2/2017 2:34 AM, ag0aep6g wrote:
> On 07/02/2017 10:55 AM, Walter Bright wrote:
>> If it is declared as:
>>
>>      inout(char)[] foo(bool condition, inout(char)[] chars);
>>
>> your specific case will work as expected. Perhaps you meant:
> 
> No, it doesn't. The function doesn't compile with that signature.
> 
> ----
> inout(char)[] foo(bool condition, inout(char)[] chars)
> {
>      if (!condition)
>          return "condition failed!"; /* Error: cannot implicitly convert 
> expression "condition failed!" of type string to inout(char)[] */
>      return chars;
> }
> ----

You're right.


More information about the Digitalmars-d mailing list