Out parameters and initialization

Ivan Senji ivan.senji_REMOVE_ at _THIS__gmail.com
Sun Feb 26 13:38:32 PST 2006


Unknown W. Brackets wrote:
> I'm thinking from the "in-side".  In my mind, if I leave off an out or 
> inout parameter, I want the result to go nowhere (but might still expect 
> the variable to exist in the function.)  I don't see how this isn't 
> logical, but I can understand how you'd disagree.

If you don't want a result the solution is easy:

void func(in int x = 7)

func();
All conditions satisfied:
* result is going nowhere
* var exists in a function
* it's value is 7

The point is: if you don't need a result, then what you probably want is 
in and not out/inout. Out is for something else.



More information about the Digitalmars-d-bugs mailing list