With the addition of the null-coalescing operator (??) in Twig, it now appears that the following two examples both provide a way to retrieve the first entry and fallback to null if no entry exists:
{# Get the first entry using the `first` method on the ElementCriteriaModel #}
{% set entry = craft.entries.section('news').first() %}
{# Get the first entry by accessing it in the result array directly #}
{% set entry = craft.entries.section('news').limit(1)[0] ?? null %}
It seems, with the addition of eager-loading and the alternative results syntax required for accessing eager-loaded elements in our templates, that the latter option may provide a consistent syntax to use throughout our templates vs. swapping between the former and the latter depending on which type of query you are performing.
Aside from the uglier syntax in the option that uses the null-coalescing operator, are there any other tradeoffs to consider in choosing the first method vs. the null-coalescing method when retrieving a single entry?
Personally I would like some (ideally syntactically nice) way of dealing with eager vs. not eager that does not require a plugin...
– Jeremy Daalder Mar 21 '16 at 01:49