Pattern matching via switch?

Steven Schveighoffer schveiguy at gmail.com
Sun Mar 15 17:55:59 UTC 2020


On 3/14/20 3:04 PM, 12345swordy wrote:
> I.E.
> 
> switch (object)
>      case Type1 t1:
>      case Type2 t2:
>      case Type3 t3:
> 

Is this a class object and you are trying to determine at runtime which 
derived type it is and perform an action based on that? Or are you 
trying to switch on the type of a concrete item?

It should technically be possible to use the fully qualified name to 
switch on, but I don't think typeid(Type1).name is usable as a switch label.

-Steve


More information about the Digitalmars-d-learn mailing list