On 23.03.25 19:37, Rowan Tommins [IMSoP] wrote:
I'm sympathetic to the problem you're trying to solve - the precedence of ?? isn't always helpful - but I'm not sure I like the proposed solution, for 3 reasons.

1) The name "nullc" is over-shortened and cryptic. The "c" looks almost like an accident, and it doesn't actually do anything if given a null.

To me, a wider approach might be more helpful, i.e. using "get" with an optional default value:

if(get($a['val']))
// equals if($a['val] ?? null)

if(get($a['val'], true))
// equals if($a['val] ?? true)

if(get($a['val], 'yes'))
// equals if($a['val] ?? 'yes')

Best,

--
Norbert Sendetzky

Aimeos GmbH
Rennbahnstr. 32
DE-22111 Hamburg

E-Mail: norb...@aimeos.com
Phone:  +49 40 8668 4492
Web: aimeos.com

Trade register: District court Hamburg HRB 143090
Managing director: Norbert Sendetzky
VAT ID: DE302287839

Reply via email to