Back to blog
documentation

First

First is the operation that returns first object from the sequence or throws an exception if the sequence does not contain elements.

Syntax

First
  : 'first' '(' LambdaExpression? ')'  
  ;

Related tokens

[LambdaExpression](../expression/lambda)

First examples

Find a table cell with the text 'Alex'. Throws when not found.

select(tableCells) // PdfTableCell[]
    ->first((item) => item.Text() == 'Alex') // PdfTableCell