Skip to content
Discussion options

You must be logged in to vote

If I may,

public class C {
    public void M() {
        var (b1, b2) = true;
    }
}

public static class Wheeeeeee {
    public static void Deconstruct(this bool b, out bool b1, out bool b2) {
     	// Are you thinking what I'm thinking, b1?
        // I think I am, b2.
        // It's tuples time!
        (b1, b2) = (b, b);
    }
}

On a more serious note, when you say that bool b1, b2 = true "works", it doesn't necessarily do what you might think it does - b1 is uninitialized, b2 is true.

So when you say that var b1, b2 = true; should be allowed a shorthand for var b1 = true; var b2 = true;, neither of those are the same as bool b1, b2 = true;.

Replies: 18 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by YairHalberstadt
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
7 participants
Converted from issue

This discussion was converted from issue #1456 on October 14, 2020 10:13.