Basic Syntax Question

John Colvin john.loughran.colvin at gmail.com
Tue Apr 2 09:52:16 PDT 2013


On Tuesday, 2 April 2013 at 16:24:46 UTC, WhatMeWorry wrote:
>
> I don't suppose there is a digital.D.beginner forum?
>
> I've been staring at this definition for about an hour and I 
> still can't decode it.
>
> int[string][double[int[]]] a;  //
> ...
> auto b = to!(short[wstring][string[double[]]])(a);  // this 
> doesn't help either
>
>
> int[string} a  // would be an Associate Array of integers with 
> a string key?
>
> int[]  // would be a dynamic array of integers,i believe?
>
> But put the int[] inside of double[] and put that inside of [] 
> and put that after the associative array, and my head can't 
> stop for spinning.
>
>
> If there is a better site or forum, please tell me and I won't 
> waste people's time here. I did buy Andrei Alexandrescu's book 
> and have it pretty well dog-eared. But i must be a pretty 
> mediocre programmer.

I'm confused, did you find that definition somewhere or did you 
write it yourself?

int[string][double[int[]]]

Let's split it up:
alias double[int[]] T;

T is an associative array with key type int[] and value type 
double

So we now have
int[string][T]
Which is an associative array with key type T and value type 
int[string] (itself an associative array)

I hope that makes more sense.


More information about the Digitalmars-d-learn mailing list