how can i use the derive-hierarchy at runtime for typechecking?

Downs default_357-line at yahoo.de
Sun Sep 23 12:27:28 PDT 2007


Jarrett Billingsley wrote:
> "Chris Nicholson-Sauls" <ibisbasenji at gmail.com> wrote in message 
> news:fcupko$kh7$2 at digitalmars.com...
> 
>> void ifIs (S, T) (S obj, void delegate(T) dg) {
>>   if (auto casted = cast(T) obj) dg(casted);
>> }
> 
> Or you could skip Downs' confusing way of writing code entirely ( ;) ) and 
> just use:
> 
> if(auto b = cast(B)foo)
> {
>     // do stuff with b
> } 
> 
> 
Well, I didn't know that! Thanks! :D
:surprised:
 --downs, learning new stuff every day! :)


More information about the Digitalmars-d-learn mailing list