Schroedinger's Ranges

WebFreak001 d.forum at webfreak.org
Thu Jun 3 07:07:36 UTC 2021


On Thursday, 3 June 2021 at 00:39:04 UTC, vacuum_tube wrote:
> I've been trying to make a struct for CSV parsing and 
> manipulating.  The code was as follows:
> ```
> struct CSVData(bool HeaderFromFirstLine)
> {
> 	char[][] header = [];
> 	char[][][] rest = [];
>
> ```
> [...]

additionally to the other comment, you probably want to use 
`string` (`immutable(char)[]`) instead of char[] here, as you 
want your data to stay the same and not be modified after 
assignment.

If you replace them with `string` and have your code be `@safe`, 
the compiler will tell you where you try to assign your char[] 
data that may be modified and in those cases you would want to 
call `.idup` to duplicate the data to make it persistent.



More information about the Digitalmars-d-learn mailing list