Posts Tagged type safety

Typesafe Dictionary

Tags: , , , , ,

One of the advantages of using Dictionary instead of Object when mapping key-value pairs is that you can use whatever type of key you want, not just a String. However, a recent comment points out that the keys are still checked with the loose equality operator (==) and you can therefore get clashes like 4 == "4". For today’s article, I’ve written a TypesafeDictionary class that allows you to overcome this limitation. Read on for the implementation, performance testing, and more.

Read the rest of this article »

4 Comments

With Blocks Part II

Tags: , , ,

I wrote an article last summer about with blocks, but really only touched on basic usage. Today I’ll delve into their internals a bit and discover some surprising aspects.

Read the rest of this article »

No Comments