What's the difference between "out" and "inout"?
Unknown W. Brackets
unknown at simplemachines.org
Sun May 21 09:19:12 PDT 2006
Image a state-based function that did not utilize a class for storing
its state information.
bool do_something(in Stream s, inout int state);
Then you might do this:
int state = 0;
while (do_something(s, state))
writefln("Current state: ", state, "\n");
This isn't the best example, I'm afraid, but it's the clearest one I can
think of at the moment. It's not needed every day, but it has definite
uses.
I guess another option would be:
bool do_something(Stream s, in int previous_state, out new_state);
But that seems silly.
-[Unknown]
> Interesting, but why? What situations need this kind of behaviour?
More information about the Digitalmars-d-learn
mailing list