Create a List or Dictionary.

Sunny yove at pm.me
Tue Jun 19 05:52:00 UTC 2018


On Monday, 18 June 2018 at 13:23:37 UTC, Cym13 wrote:

Yes, this is what need, thank you very much for your help. :-)

> On Monday, 18 June 2018 at 11:44:43 UTC, Sunny wrote:
>> [...]
>
> If I read you well it seems the simplest equivalent code would 
> be:
>
>     struct MusicItem {
>         string URL;
>         string Artist;
>         string Title;
>         string Cover;
>         string Duration;
>     }
>
>     MusicItem[] musicList;
>
> You could technically use tuples to get to the same point but I 
> don't really
> see a point, structs fit that purpose very well.
>
> Then you can:
>
>     musicList ~= MusicItem(url, artist, title, cover, duration);
>     musicList = [musicItem1, musicItem2];
>
> or for dictionnaries:
>
>     MusicItem[string] musicDictionnary = [
>         "shortID1": MusicItem(foo, bar, baz, bak, biz, sub),
>         "shortID2": MusicItem(foo, bar, baz, bak, biz, sub),
>     ];
>
> etc.



More information about the Digitalmars-d-learn mailing list