Re: Inline conditional that returns null if falsy

From: Date: Wed, 24 Feb 2021 15:29:08 +0000
Subject: Re: Inline conditional that returns null if falsy
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-113244@lists.php.net to get a copy of this message
Javascript has this now though support isn't widespread.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Optional_chaining

The most similar way to do it in PHP would be ?->

On Fri, Feb 12, 2021 at 1:46 PM Ben Ramsey <ben@benramsey.com> wrote:

> > The => is just a suggestion, other options using existing keywords is:
> > return expr() then output();
> > return expr(): output();
> >
> > I do not know if other languages support something like that.
>
>
> I think it might be a good idea to check other languages to see if they
> support something like this. We could use their examples as points of
> reference for discussing whether to include this functionality in PHP.
>
> Cheers,
> Ben
>
>
>


Thread (23 messages)

« previous php.internals (#113244) next »