Thread overview | |||||
---|---|---|---|---|---|
|
July 20, 2006 dmd v.163 foreach question: int[] is not an array of int[] | ||||
---|---|---|---|---|
| ||||
My question is this, with the current code, why is the first statement valid but as soon as you try to iterate with foreach the code becomes invalid? I get the error "int[] is not an array of int[]". Bug? Misunderstanding? Thanks. ~ Clay int[][char[]] bob; int main() { // this code is valid int[] b1 = bob["world"]; foreach(char[] k; bob.keys) // int[] is not an array of int[] foreach(int[] b; bob[k]) { } return 0; } |
July 20, 2006 Re: dmd v.163 foreach question: int[] is not an array of int[] | ||||
---|---|---|---|---|
| ||||
Posted in reply to clayasaurus | If bob[k] is an int[], then the foreach is iterating int's, not int[]'s. You probably meant foreach( int b; bob[k]). L. "clayasaurus" <clayasaurus@gmail.com> wrote in message news:e9n69q$1a51$1@digitaldaemon.com... > My question is this, with the current code, why is the first statement valid but as soon as you try to iterate with foreach the code becomes invalid? I get the error "int[] is not an array of int[]". Bug? Misunderstanding? Thanks. > > ~ Clay > > int[][char[]] bob; > > int main() > { > // this code is valid > int[] b1 = bob["world"]; > > > foreach(char[] k; bob.keys) > // int[] is not an array of int[] > foreach(int[] b; bob[k]) > { > } > > return 0; > } |
July 20, 2006 Re: dmd v.163 foreach question: int[] is not an array of int[] | ||||
---|---|---|---|---|
| ||||
Posted in reply to Lionello Lunesu | Lionello Lunesu wrote:
> If bob[k] is an int[], then the foreach is iterating int's, not int[]'s. You probably meant foreach( int b; bob[k]).
>
> L.
Thanks!
~ Clay
|
Copyright © 1999-2021 by the D Language Foundation