Rectangular or 2d associative arrays
Frits van Bommel
fvbommel at REMwOVExCAPSs.nl
Fri Mar 16 10:47:46 PDT 2007
Falk Henrich wrote:
> David Freitas wrote:
>
>> int[char] x; // Visually: = ['a':1, 'b':2] // associative
>> array x['b'] = 123;
>> writefln(x); // this prints out: [b:2063597568]
>> writefln(x['b']); // this prints out: 123
>>
>> This just doesn't seem intuitive to me? Why is there a "garbage" value
>> being printed out?
>
> What would you expect D to print out? How can the language know how to
> interpet arrays of some type? Hard coding some special output format for
> all types of arrays into the language is not a wise idea.
Writef(ln) and other functions that do formatting use the TypeInfo
provided by their varargs to construct readable representations of their
parameters. This case just seems to be buggy.
More information about the Digitalmars-d-learn
mailing list