Not initialized out argument error
Jesse Phillips via Digitalmars-d
digitalmars-d at puremagic.com
Tue Jun 17 21:07:59 PDT 2014
On Tuesday, 17 June 2014 at 12:04:05 UTC, Kapps wrote:
> C# forces you to set a default value for out parameters, and I
> personally find it annoying. The very nature of out parameters
> is often that you use it in a situation where there *may* be a
> result. Again using a C# example, 'bool
> Dictionary.TryGetValue(key, out foo)'. I don't care what the
> value of foo is if that returns false, yet the method still has
> to manually initialize it to what that particular
> implementation feels like (which is not guaranteed to be any
> particular value). I prefer D's approach where you have a
> guaranteed value that it gets default initialized to, and don't
> have to manually initialize it to some value if it doesn't make
> sense to assign a value.
It seems to me the check should be, did the code assign a value
to this variable. When it happens and under what conditions isn't
important, but it should do it once. But such a check isn't
likely to have great value.
More information about the Digitalmars-d
mailing list