Rectangular or 2d associative arrays

David Freitas jddcef at gmail.com
Fri Mar 16 09:20:35 PDT 2007


Hello All!

Look at this small program and look at the output in the comments:
///////////////////////////////////
 import std.stdio;
 void main() 
 {
         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? 

Using a linux machine, with dmd 1.009.

Cheers!

David


More information about the Digitalmars-d-learn mailing list