So what does (inout int = 0) do?

Timon Gehr via Digitalmars-d digitalmars-d at puremagic.com
Fri Apr 15 14:20:34 PDT 2016


On 15.04.2016 23:03, Andrei Alexandrescu wrote:
> On 04/15/2016 04:47 PM, Steven Schveighoffer wrote:
>> There's no difference between a function that declares its variables
>> inout within its parameters or one that declares them locally.
>
> So now we get to things like:
>
> void fun() {
>    inout int ohHello = 42;
>    ...
> }
>
> How to explain such a construct? Not to mention globals of that type are
> not allowed.
>
>
> Andrei
>

It's an int that has not decided yet whether it wants to be mutable, 
const or immutable and goes out of scope before it is able to make up 
its mind.


More information about the Digitalmars-d mailing list