For example I have
private void test(Action<ValueTuple<string, int>> fn)
{
fn(("hello", 10));
}
test(t =>
{
var (s, i) = t;
Console.WriteLine(s);
Console.WriteLine(i);
});
I would like to write something like this
private void test(Action<ValueTuple<string, int>> fn)
{
fn(("hello", 10));
}
test((s,i) =>
{
Console.WriteLine(s);
Console.WriteLine(i);
});
Is this possible with some proper notation?
You can shorten it to:
void test( Action<ValueTuple<string, int>> fn)
{
fn(("hello", 10));
}
test(((string s, int i) t) =>
{
Console.WriteLine(t.s);
Console.WriteLine(t.i);
});
Hopefully, one day we might be able to splat the parameters from a tuple to the method invocation:
void test(Action<ValueTuple<string, int>> fn)
{
fn(@("hello", 10)); // <-- made up syntax
}
test((s, i) =>
{
Console.WriteLine(s);
Console.WriteLine(i);
});
But not at the moment.