Pattern matching via switch?

12345swordy alexanderheistermann at
Sun Mar 15 18:22:47 UTC 2020

On Sunday, 15 March 2020 at 17:55:59 UTC, Steven Schveighoffer 
> 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

It is an example from c#.
object is the top type in that language.

More information about the Digitalmars-d-learn mailing list