Thread overview | ||||||||
---|---|---|---|---|---|---|---|---|
|
March 12, 2004 const for associative arrays? | ||||
---|---|---|---|---|
| ||||
Is there a way to declare and initialize associative arrays? Something along the lines of: const int[char[]] foo = list of pairs? Thanks. |
March 12, 2004 Re: const for associative arrays? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Steve Adams | "Steve Adams" <adamss@ascinet.com> wrote in message news:40521D81.4030808@ascinet.com... > Is there a way to declare and initialize associative arrays? Something along the lines of: > > const int[char[]] foo = list of pairs? Currently, there isn't. One way to do it is to use a module constructor to load up the array. |
March 12, 2004 Re: const for associative arrays? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Steve Adams | I think you will find that info here: http://www.digitalmars.com/d/arrays.html Phill. "Steve Adams" <adamss@ascinet.com> wrote in message news:40521D81.4030808@ascinet.com... > Is there a way to declare and initialize associative arrays? Something along the lines of: > > const int[char[]] foo = list of pairs? > > Thanks. |
March 12, 2004 Re: const for associative arrays? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | When do you think that might become available? I'm really looking forward to it personally, because I have a lot of those module constructors doing just that, and it would be nice to get it all in one statement.
I'm sure its all been said before, but I'm personally a fan of the : syntax...
const int[char[]] FOO = [
"abc" : 1,
"def" : 2,
"ghi" : 3
];
Feels consistant with the struct syntax, and reminds me of Python all at once. :)
-C. Sauls
-Invironz
Walter wrote:
> "Steve Adams" <adamss@ascinet.com> wrote in message
> news:40521D81.4030808@ascinet.com...
>
>>Is there a way to declare and initialize associative arrays? Something
>>along the lines of:
>>
>> const int[char[]] foo = list of pairs?
>
>
> Currently, there isn't. One way to do it is to use a module constructor to
> load up the array.
|
March 13, 2004 Re: const for associative arrays? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | Walter wrote:
> "Steve Adams" <adamss@ascinet.com> wrote in message
> news:40521D81.4030808@ascinet.com...
>
>>Is there a way to declare and initialize associative arrays? Something
>>along the lines of:
>>
>> const int[char[]] foo = list of pairs?
>
>
> Currently, there isn't. One way to do it is to use a module constructor to
> load up the array.
>
>
Thanks, I'll use that approach.
|
March 13, 2004 Re: const for associative arrays? | ||||
---|---|---|---|---|
| ||||
Posted in reply to C. Sauls | "C. Sauls" <ibisbasenji@yahoo.com> wrote in message news:c2tess$2mki$1@digitaldaemon.com... > When do you think that might become available? I'm really looking forward to it personally, because I have a lot of those module constructors doing just that, and it would be nice to get it all in one statement. Not for 1.0, but better array literals are a good candidate for 2.0. |
Copyright © 1999-2021 by the D Language Foundation