Improvements to switch

IchorDev zxinsworld at gmail.com
Sat Apr 27 14:58:19 UTC 2024


On Tuesday, 16 April 2024 at 16:00:48 UTC, Basile B. wrote:
> About this, the main point is rather
>
> ```d
> /*-->*/ const /*<--*/ int myvalue = switch(code) {
>     // ...
> };
> ```
>
> "ah finally you can define a const var decl that relies on 
> branching" (without using the conditional expression...)

You can already do that.
```d
const string myValue = (){
	switch(code){
		case 1:    return "what";
		case 2, 3: return "ok";
		default:   return "no";
	}
}();


More information about the dip.ideas mailing list