My new favorite D feature

Gregor Richards Richards at codu.org
Tue Dec 19 21:47:43 PST 2006


Tim Keating wrote:
> At least for then next couple of hours, anyway:
> 
> 	int i = 100;
> 
> 	if (i = 2);
> 	{
> 		writefln("We shouldn't be here");
> 	}
> 
> Yields:
> 
> 	use '{ }' for an empty statement, not a ';'
> 
> Instead of blithely steping into that block. As just happened in my C++ 
> program, wasting 30 minutes of my life while I tried to figure out why 
> the heck that block kept getting executed.
> 
> TK

This has actually annoyed me a bit, but not enough to think it's not 
worth it.

for (i = 0; foo[i] != TERMINATOR; i++);

  - Gregor Richards



More information about the Digitalmars-d mailing list