On Monday, 20 August 2018 at 09:23:27 UTC, Andrey wrote:
Hello,

I have a function and a struct:
void foo(ref Data data) { ... }

struct Data
{
   int a;
   string text;
}

How to pass struct into function without naming its type?

This doesn't work:

foo({1234, "Hello!"});

Create an overload of foo that takes two arguments and combines them into a `Data` struct internally:

void foo(int a, string text)
{
    Data data = {a, text};
    foo(data);
}

Reply via email to