Re: Iterating over the tupleof of a struct

2014-08-23 Thread Suliman via Digitalmars-d-learn
How can I feel struct with foreach loop? struct ConfigStruct { string [string] key1; string [string] key2; } ConfigStruct confstruct; foreach (i, line; readText(ConfigName).splitLines()) { string [] keyvalue = line.split(=); confstruct.key1[keyvalue[0]] = keyvalue[1]; } it's ok for 1

Re: Iterating over the tupleof of a struct

2014-08-23 Thread Meta via Digitalmars-d-learn
On Saturday, 23 August 2014 at 01:56:06 UTC, Dicebot wrote: On Saturday, 23 August 2014 at 01:32:13 UTC, Meta wrote: On Saturday, 23 August 2014 at 01:24:10 UTC, Meta wrote: What is happening here? Are these two extra ulongs the offsets of the fields in the struct? And I just realized that

Re: Iterating over the tupleof of a struct

2014-08-23 Thread Ali Çehreli via Digitalmars-d-learn
On 08/23/2014 10:21 AM, Meta wrote: On Saturday, 23 August 2014 at 01:56:06 UTC, Dicebot wrote: On Saturday, 23 August 2014 at 01:32:13 UTC, Meta wrote: On Saturday, 23 August 2014 at 01:24:10 UTC, Meta wrote: What is happening here? Are these two extra ulongs the offsets of the fields in the

Re: Iterating over the tupleof of a struct

2014-08-23 Thread Meta via Digitalmars-d-learn
On Saturday, 23 August 2014 at 20:34:35 UTC, Ali Çehreli wrote: There are a number of inconsistencies around tuples. The behavior you expect is present for ranges that return tuple fronts: import std.stdio; import std.typecons; import std.range; void main() { auto t = [ tuple(1.5, 100),

Iterating over the tupleof of a struct

2014-08-22 Thread Meta via Digitalmars-d-learn
Something weird happens when I try to foreach over test.tupleof. If the foreach loop has 2 variables like so: struct Test { string name = 'null'; int id; } void main() { auto test = Test(); assert(test.name == 'null'); assert(test.id == 0);

Re: Iterating over the tupleof of a struct

2014-08-22 Thread Meta via Digitalmars-d-learn
On Saturday, 23 August 2014 at 01:24:10 UTC, Meta wrote: What is happening here? Are these two extra ulongs the offsets of the fields in the struct? And I just realized that that's obviously not the case. It's just an iteration variable. Problem solved.

Re: Iterating over the tupleof of a struct

2014-08-22 Thread Dicebot via Digitalmars-d-learn
On Saturday, 23 August 2014 at 01:32:13 UTC, Meta wrote: On Saturday, 23 August 2014 at 01:24:10 UTC, Meta wrote: What is happening here? Are these two extra ulongs the offsets of the fields in the struct? And I just realized that that's obviously not the case. It's just an iteration