Rafael,

One point of clarity:

On Wed, Jul 18, 2012 at 10:15 AM, Rafael Dohms <lis...@rafaeldohms.com.br>wrote:

> Hey Everyone,
>
> With the syntax improvements for 5.4 and some of the de-referencing work,
> code looks so much sleeker then before, but there is still one use case
> that really bugs me.
>
> Given this code:
>
> $width = (isset($config['width']))? $config['width'] : 300;
>
> The code is pretty straight forward, if width is set in the array, use it
> otherwise use 300.
>
> This code would look much better if it could make use of the ternary
> operator
>
> $width = $config['width'] ?: 300;
>
> The only reason for this to not work is: it throws a notice if the array
> key is not there (which is the case we are covering anyway)
>
> This is basically because the ternary operator does not do a internal
> implicit isset, only an empty.
>

It does not do an empty. Empty would avoid notices as well. All it does is
an implicit bool cast...


> Does this seem like a possible improvement we can work on? Anyone
> interested in championing the change?
>

I like it in principle. My only concern is *why* wasn't it done this way in
the first place... Is there a reason?

Anthony

Reply via email to