Suliman:
void main()
{
auto result = readconfig();
foreach (_; result)
{
// I want to iterate result that I got from structure.
}
}
auto readconfig()
{
struct ConfigStruct
{
string key1;
string key2;
}
ConfigStruct confstruct = ConfigStruct();
confstruct.key1="Ivan";
confstruct.key2="admin";
return confstruct;
}
Be careful to make ConfigStruct a static struct.
auto readconfig() {
static struct ConfigStruct {
string key1, key2;
}
return ConfigStruct("Ivan", "admin");
}
void main() {
import std.stdio;
auto result = readconfig();
foreach (field; result.tupleof) {
writeln(field);
}
}
Bye,
bearophile