Skip to content

Latest commit

 

History

History
46 lines (29 loc) · 755 Bytes

File metadata and controls

46 lines (29 loc) · 755 Bytes

First<T> class method

Project: Array Utilities Unit

Unit: DelphiDabbler.Lib.ArrayUtils

Record: TArrayUtils

Applies to: ~>0.1

class function First<T>(const A: array of T): T;
  static;

Description

Returns the first element of a non-empty array.

Parameters:

  • A - The array on which to operate.

Returns:

  • The required first element.

Precondition:

  • A must not be empty. An EAssertionFailed exception is raised otherwise.

Example

procedure First_Eg;
var
  A: TArray<Integer>;
begin
  A := TArray<Integer>.Create(1, 2, 3);
  Assert(TArrayUtils.First<Integer>(A) = 1);
end;

See Also