C#'s 'is' equivalent in D

Just Dave abcdef at 1234.com
Thu Oct 10 15:57:45 UTC 2019


On Thursday, 10 October 2019 at 15:53:20 UTC, Adam D. Ruppe wrote:
> On Thursday, 10 October 2019 at 15:47:58 UTC, Just Dave wrote:
>>     if (obj is Person person)
>
> Looks the same as D's
>
> if(auto person = cast(Person) obj) {
>   // use person in here
> } else {
>   // it was some other type
> }

Excellent!


More information about the Digitalmars-d-learn mailing list