digitalmars.D - Initializing associative arrays
- Chris Stevenson (4/4) Aug 18 2004 Does D provide a way to initial;ize an associative array? I want to use...
- Ilya Minkov (5/8) Aug 18 2004 Unfortunately, currently there are no associative array literals. Thus
- Arcane Jill (8/17) Aug 18 2004 I have considered before the notion of cobbling one together with some i...
- Sha Chancellor (10/22) Aug 18 2004 int[3] a = [ 1:2, 3 ]; // a[0] = 0, a[1] = 2, a[2] = 3
- Stewart Gordon (7/10) Aug 22 2004 Been an issue for a while.
Does D provide a way to initial;ize an associative array? I want to use a static const associative array in a class. I'm beginning to think I'll have to drop the const part and use a static initializer instead. --Chris Stevenson
Aug 18 2004
Chris Stevenson schrieb:Does D provide a way to initial;ize an associative array? I want to use a static const associative array in a class. I'm beginning to think I'll have to drop the const part and use a static initializer instead.Unfortunately, currently there are no associative array literals. Thus you won't be able to create a constant associative array. Walter hasn't expressed his mind on it, although there were a number of proposals. -eye
Aug 18 2004
In article <cfvd5q$2b60$1 digitaldaemon.com>, Ilya Minkov says...Chris Stevenson schrieb:I have considered before the notion of cobbling one together with some inline assembler (or, more likely, writing a tool to automate such an asm block), but there's one small problem - from the D Manual page "Application Binary Interface":Does D provide a way to initial;ize an associative array? I want to use a static const associative array in a class. I'm beginning to think I'll have to drop the const part and use a static initializer instead.Unfortunately, currently there are no associative array literals. Thus you won't be able to create a constant associative array. Walter hasn't expressed his mind on it, although there were a number of proposals.Associative Arrays TBDBah! I would like to know when this small piece of documentation could be completed. Arcane Jill
Aug 18 2004
In article <cfvd5q$2b60$1 digitaldaemon.com>, Ilya Minkov <minkov cs.tum.edu> wrote:Chris Stevenson schrieb:int[3] a = [ 1:2, 3 ]; // a[0] = 0, a[1] = 2, a[2] = 3 This is most handy when the array indices are given by enums: enum Color { red, blue, green }; int value[Color.max] = [ blue:6, green:2, red:5 ]; The logical jump for me would be: int[char[]] foo = [ "joe":5, "fran":10, "bob":20 ]; However, I don't think it's currently implemented.Does D provide a way to initial;ize an associative array? I want to use a static const associative array in a class. I'm beginning to think I'll have to drop the const part and use a static initializer instead.Unfortunately, currently there are no associative array literals. Thus you won't be able to create a constant associative array. Walter hasn't expressed his mind on it, although there were a number of proposals. -eye
Aug 18 2004
Chris Stevenson wrote:Does D provide a way to initial;ize an associative array? I want to use a static const associative array in a class. I'm beginning to think I'll have to drop the const part and use a static initializer instead.Been an issue for a while. http://www.digitalmars.com/drn-bin/wwwnews?D/26695 Stewart. -- My e-mail is valid but not my primary mailbox. Please keep replies on on the 'group where everyone may benefit.
Aug 22 2004