What is the use case for this weird switch mecanism
Era Scarecrow
rtcvb32 at yahoo.com
Wed Oct 31 15:13:25 PDT 2012
On Wednesday, 31 October 2012 at 22:01:36 UTC, bearophile wrote:
> Chris Nicholson-Sauls:
>
>> There is also the trick of doing 'switch(val) with(EnumType)
>> {...}'
>
> What about writing with(EnumType) switch(val) {...} ?
Maybe... But a problem arises when it's function wide, and
should be able to replace (hopefully) any block. Assuming there's
no syntactical issues that may break other code.
int func()
with(EnumType) { //won't compile
}
int func() {
with(EnumType) { //compiles but seems excessive when it doesn't
need to...
}
}
But 'switch with' seems the proper way to put it in my mind.
More information about the Digitalmars-d
mailing list