On 6/9/13, bearophile <bearophileh...@lycos.com> wrote: > It's a quite useful statement, especially with enumerations or > associative array literals, to avoid repeating many times their > name: > > switch (en) with (MyEnum) { > case foo: ... > case bar: ... > }
Yep, I use this idiom a lot. It's also very useful in unittests, to avoid copy-pasting code and polluting the namespace. A contrived example: ----- class C { int x, y; this() { x = 1; y = 2; } } unittest { with (new C) { assert(x == 1); assert(y == 2); } } ----- There are some bugs with it currently, but I think they're fixable.