Pattern matching via switch?
rikki cattermole
rikki at cattermole.co.nz
Tue Mar 17 12:04:48 UTC 2020
On 18/03/2020 12:59 AM, Steven Schveighoffer wrote:
> I think he's looking for object pattern matching. i.e. you give it an
> Object, and it runs a block of code based on the derived type.
In case this syntax is unknown:
if (MyObject1 myObject = cast(MyObject1)obj) {
...
} else if (MyObject2 myObject = cast(MyObject2)obj) {
...
} else {
...
}
More information about the Digitalmars-d-learn
mailing list