How to simplify nested ifs

Tony tonytdominguez at aol.com
Fri Mar 16 16:38:51 UTC 2018


On Tuesday, 13 March 2018 at 12:23:06 UTC, Ozan Süel wrote:

> if (source?pool?repository?directory?users) // do something
>

That type of chain is sometimes referred to as a "train wreck" 
(see Law of Demeter).

If this is a common lookup it could be:

if (source && source.GotSomeUsers() )




More information about the Digitalmars-d-learn mailing list