function ItemList::last

Returns the last item in this list.

Return value

\Drupal\Core\TypedData\TypedDataInterface|null The last item in this list, or NULL if there are no items.

Overrides ListInterface::last

File

core/lib/Drupal/Core/TypedData/Plugin/DataType/ItemList.php, line 310

Class

ItemList
A generic list class.

Namespace

Drupal\Core\TypedData\Plugin\DataType

Code

public function last() : ?TypedDataInterface {
  return $this->get($this->count() - 1);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.