Difference between revisions of "Programming in D for Java Programmers"
(Downcasting) |
m (O3o moved page Coming From/Java to Programming in D for Java Programmers) |
||
(One intermediate revision by the same user not shown) | |||
Line 12: | Line 12: | ||
/* use cat */ | /* use cat */ | ||
}</syntaxhighlight> | }</syntaxhighlight> | ||
+ | |||
+ | [[Category:Languages versus D]] |
Revision as of 12:41, 15 April 2015
Downcasting
The Java way
if (animal instanceof Cat)
{
Cat cat = (Cat) animal;
/* use cat */
}
The D way
if(auto cat = cast(Cat) animal)
{
/* use cat */
}