Re: Switch between two structs with csvreader

2020-11-07 Thread Selim Ozel via Digitalmars-d-learn
On Friday, 6 November 2020 at 19:35:47 UTC, H. S. Teoh wrote: You can use the typeof() operator to capture the type of a long, unwieldy type in an alias. This is useful if you ever need to store such a return type somewhere, e.g.: alias T = typeof(csvReader(...)); struct

Re: Switch between two structs with csvreader

2020-11-06 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Nov 06, 2020 at 07:17:53PM +, Selim Ozel via Digitalmars-d-learn wrote: > On Thursday, 5 November 2020 at 22:36:36 UTC, Anonymouse wrote: > > If I'm not mistaken the `csvReader` function returns a range struct, > > and the full type is something long and unwieldy like > >

Re: Switch between two structs with csvreader

2020-11-06 Thread Selim Ozel via Digitalmars-d-learn
On Thursday, 5 November 2020 at 22:36:36 UTC, Anonymouse wrote: If I'm not mistaken the `csvReader` function returns a range struct, and the full type is something long and unwieldy like `CsvReader!(struct_type1, cast(Malformed)1, string, dchar, string[])`. So just think of `records` as being

Re: Switch between two structs with csvreader

2020-11-05 Thread Anonymouse via Digitalmars-d-learn
On Thursday, 5 November 2020 at 21:18:52 UTC, Selim Ozel wrote: auto records = rawtext.csvReader!struct_type1(';'); D is statically typed and `auto` means "deduce this type for me based on this one function's return value". It is not like JavaScript's `var` whose type may change. If I'm

Switch between two structs with csvreader

2020-11-05 Thread Selim Ozel via Digitalmars-d-learn
Hi There, I am trying to switch between two structs as I am using the csvReader on a raw string. The pseudo-code below throws a "cannot implicitly convert" error due to difference between struct_type1 and struct_type2. I must be doing something wrong or have a wrong understanding of how this