I wish I could use D for everything

Steven Schveighoffer schveiguy at yahoo.com
Wed Apr 29 18:49:28 PDT 2009


I've written this handy template in C# called DictionaryValueEnum.  It  
returns an Enumerator for a Dictionary that enumerates only the values.

The sole purpose of this enum is so I can have something reasonable when  
iterating through the values in a dictionary instead of:

foreach(KeyValuePair<KeyType, ValueType> kvp in myDictionary)
{
   ValueType vt = kvp.Value;
   ...
}

But of course, C#, like Java, has no free functions, so I have to  
encapsulate everything in a class, so my code looks like this:

foreach(ValueType vt in DictionaryValueEnum.enumerate(myDictionary))
{
   ...
}

Oh, how nice it would be to avoid all that crap and just type:

foreach(vt; myDictionary)
{
   ...
}

And I just typed about the 5 billionth time:

if(ReferenceEquals(myObj, blah))

Written in D would be:

if(myObj is blah)

I can't wait for D to take over the world, so I no longer have to write in  
this horrid language ;)

-Steve



More information about the Digitalmars-d mailing list