In Python one can do:
foo = {}
assert foo.get('bar', 'baz') == 'baz'
In PHP one can go for a trinary operator as in:
$foo = array();
assert( (isset($foo['bar'])) ? $foo['bar'] : 'baz' == 'baz' );
I am looking for a golf version. Can I do it shorter/better in PHP?
UPDATE [March 2020]:
assert($foo['bar'] ?? 'baz' == 'baz');
It seems that Null coalescing operator ?? is worth checking out today.
found in the comments below (+1)