How to simplify nested ifs

Ozan Süel ozan.sueel at gmail.com
Tue Mar 13 12:23:06 UTC 2018


Hi

I have a construction like the following

if (source) {
   if (source.pool) {
     if (source.pool.repository) {
       if (source.pool.repository.directory) {
	if (source.pool.repository.directory.users) {
	  // do something

Any chance to simplify this nested ifs?
I know some languages has a way like.

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


Similar ways in D?

Thanks and Regards, Ozan


More information about the Digitalmars-d-learn mailing list