Skip to content

Instantly share code, notes, and snippets.

@jcouv
Created March 8, 2019 23:11
Show Gist options
  • Save jcouv/97104c720e5004aecc465bec534adfdd to your computer and use it in GitHub Desktop.
Save jcouv/97104c720e5004aecc465bec534adfdd to your computer and use it in GitHub Desktop.

Do we look at tuples like Pair<T1, T2> or like locals?

// current behavior is similar to Pair<T1, T2> except that we’re able to initialize the state of the fields in tuple literals
static void M(string? x, string y)
{
    (string, string) t = (x, y); // warning: (string?, string) mismatch
    t.Item1.ToString();          // warning: may be null
    var t2 = Identity(t);        // infers `(string, string)`
}
// an alternative is to treat tuples like we do locals
static void M(string? x, string y)
{
    (string, string) t = (x, y); // W-warning: x is possibly null
    t.Item1.ToString();          // warning: may be null
    var t2 = Identity(t);        // infers `(string?, string)`
}
@jcouv
Copy link
Author

jcouv commented Mar 9, 2019

We concluded we should stick with current approach.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment