-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Description
General
Version : 3.1
VisualStudio: 2019 16.5.4
public Boolean TryTest(String X, out String Y)
{
Lazy<Dictionary<String, String>> A, B;
if (A.IsValueCreated ? A.Value.TryGetValue(X, out Y) : false
|| B.IsValueCreated ? B.Value.TryGetValue(X, out Y) : false)
return true
Y = null;
return false
}is the same as
public Boolean TryTest(String X, out String Y)
{
Lazy<Dictionary<String, String>> A, B;
if (A.IsValueCreated && A.Value.TryGetValue(X, out Y)
|| B.IsValueCreated && B.Value.TryGetValue(X, out Y))
return true
Y = null;
return false
}the above snippet works with no issue but the first one will throw a compile error stating that Y would not be set by the if-statements return.
this has no real implications with this example as using && is by far much better then using ? : but as it stands it is an error in the compilers ability to predict and as such should be fixed as it may have some other unforeseen implication in another project.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels