Programming in D, page 604 - static foreach fails. Is the code obsolete?

Brother Bill brotherbill at mail.com
Sun Oct 5 23:55:44 UTC 2025


```
import std.stdio;

void main(string[] args)
{
	writeln("args: ", args);
	
	theSwitchStatement:
		switch (args.length)
		{
			static foreach (i; 1 .. 3)
			{
				case i:
					writeln(i);
					break theSwitchStatement;
			}

			default:
				writeln("default case");
				break;  // This may also be:  break theSwitchStatement;
		}
}

```


More information about the Digitalmars-d-learn mailing list