Convert struct to set of fields and pass it's to constructor
Suliman via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Wed Feb 1 05:37:27 PST 2017
Class constructor accept only set if fields like
this(string login, string pass)
Can I create structure, fill it, and than pass to constructor?
Like this:
```
import std.stdio;
struct ConnectSettings
{
string login;
string pass;
};
ConnectSettings cs;
void main()
{
cs.login = "admin";
cs.pass = "mypass";
}
```
and than pass to constructor it's like:
`... new SomeClass(cs)`
I tried, but get error, that ctor accept only fields list. Can I
unroll struct to it?
More information about the Digitalmars-d-learn
mailing list