On 14/03/2018 1:23 AM, Ozan Süel wrote:

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

if (source !is null &&
        source.pool !is null &&
        source.pool.repository !is null &&
        source.pool.repository.directory !is null &&
        source.pool.repository.directory.users !is null) {

That is what I'd do.

Reply via email to