D idioms list
ponce via Digitalmars-d-announce
digitalmars-d-announce at puremagic.com
Thu Jan 15 00:46:24 PST 2015
On Thursday, 15 January 2015 at 06:02:13 UTC, Vlad Levenfeld
wrote:
> For optimal AA lookup, this idiom is also nice if you only need
> the result for one line:
>
> if (auto found = key in AA)
> do_stuff (found);
Having a declaration in an "if" could be another entry together
with:
if (auto inst = cast(SubClass)myObject)
do_stuff(inst);
How to do "instanceof" is quite a common question on IRC.
More information about the Digitalmars-d-announce
mailing list