I have a vector class with two deconstruction methods as follows:
public readonly struct Vector2
{
public readonly double X, Y;
...
public void Deconstruct( out double x, out double y )
{
x = this.X;
y = this.Y;
}
public void Deconstruct( out Vector2 unitVector, out double length )
{
length = this.Length;
unitVector = this / length;
}
}
Somewhere else I have:
Vector2 foo = ...
(Vector2 dir, double len) = foo;
This gives me:
CS0121: The call is ambiguous between the following methods or properties: 'Vector2.Deconstruct(out double, out double)' and 'Vector2.Deconstruct(out Vector2, out double)'
How is this ambiguous?
Edit: Calling Deconstruct manually works fine:
foo.Deconstruct( out Vector2 dir, out double len );
Deconstruction posits that the author and the text are entirely separate entities because there is a quasi-infinite number of interpretations of any given text, which are equal in value; therefore, giving the author prominence in light of such infinity, is incoherent, as, the origin of this is arbitrary.
Deconstruction is generally presented via an analysis of specific texts. It seeks to expose, and then to subvert, the various binary oppositions that undergird our dominant ways of thinking—presence/absence, speech/writing, and so forth. Deconstruction has at least two aspects: literary and philosophical.
/ˌdiː.kənˈstrʌkʃ. ən/ the act of breaking something down into its separate parts in order to understand its meaning, especially when this is different from how it was previously understood: her complex deconstruction of the Asian stereotype.
[Deconstruction] signifies a project of critical thought whose task is to locate and 'take apart' those concepts which serve as the axioms or rules for a period of thought, those concepts which command the unfolding of an entire epoch of metaphysics.
This is by design in C#. Overloads of Deconstruct must have different arity (number of parameters), otherwise they are ambiguous.
Pattern-matching does not have a left-hand-side. More elaborate pattern-matching scheme is to have a parenthesized list of patterns to match, and we use the number of patterns to decide which Deconstruct to use. - Neal Gafter https://github.com/dotnet/csharplang/issues/1998#issuecomment-438472660
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With